MPesi
MPesi

Reputation: 357

Is there a way to improve query time across relations?

Is there a way to improve query time across relations? Yet to measure, but I'm currently modeling my data in Memgraph in such a way that I will have several versions, and a typical query will look like:

MATCH (:Version { major: $major, minor: $minor })--(t:Thing { name: $name }) 

Of course, I can create an index over major/minor and over the name, but I worry that given nearly all queries will actually look for a composite index + relation it'll still have some performance impact. I will need to measure this, but wanted to see whether someone has some insight for me already, and if there is something I can do to improve this. Also, there are < 100 of :Version and > 100000 of :Thing, so essentially the degree of :Version will be very high) Wondering if I should convert this to be a single field on :Thing, for better indexing

Upvotes: 0

Views: 29

Answers (1)

MPesi
MPesi

Reputation: 357

After exploring, I would say that the current model looks fine. It would be good to have an index on the name of the :Thing nodes, for sure, creating it on :Version is questionable and should be measured. Use EXPLAIN/PROFILE query to see different options and test the performance But I think

MATCH (t:Thing {name : $name})--(:Version {major: $major, minor: $minor})

with index on Thing(name) should be enough. I did reverse the order but it shouldn't matter actually.

Upvotes: 0

Related Questions