Reputation: 3099
I am running a query on 3 tables which are connected with the same id of an application. However, this query runs too long to get any result. How can I optimize this query? The application_id by which both edges are created should be the same for both Sms and Pcb nodes.
This is the query itself:
MATCH (pcb:PhoneContactsBook)-[:APP_PCB]->(a:Applications)-[:APP_SMS]->(sms:Sms)
RETURN distinct a.application_id
To get the query plan, I run this query with LIMIT 200,000
and I get 1046648 total db hits in 1251 ms.
Here is the query plan:
Upvotes: 0
Views: 36
Reputation: 7478
Firstly, to get the query plan, you can use EXPLAIN
instead of PROFILE
:
EXPLAIN
do not run the query and only give you the query plan of the queryPROFILE
executes the query, and give you the result of your query + its query planI don't see any optimization here, because you are asking the database to give you all the instance of a specific pattern and there is no where clause, no sub-statement, no aggregation ...
But it seems that you have a lot instances of this pattern in your database (more than 200 000), that's why this query takes some times (~6 microsecondes per pattern is not bad ^^)
Upvotes: 1