Search code examples
memgraphdb

Are composite indexes supported in Memgraph?


Can I create index on more than one property for any given label? I am running query like:

MATCH (n:Node) WHERE n.id = xyz AND n.source = abc;

and I want to know whether I can create multiple property indexes and if not, is there a good way to query for nodes matching multiple properties?


Solution

  • Memgraph does not support composite indexes, but you can create multiple label-property indexes. For example, run

    CREATE INDEX ON Node(id);
    CREATE INDEX ON Node(source);
    

    To check if they are properly created, run SHOW INDEX INFO;.

    Use EXPLAIN/PROFILE query (inspecting and profiling queries) to see different options and test the performance, maybe one label-property index is good enough.