Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-06-2021 02:46 AM
Server version 4.3.1
1. Local create index
CREATE INDEX Supply_id_index IF NOT EXISTS FOR (l:SupplyPlan) ON (l.id);
2. execute explain
explain MATCH (shipment:`Shipment` {tenantId: '0804', type: 'Shipment'})
WHERE EXISTS {
MATCH (shipment:`Shipment`)
-[:`Shipment_SupplyPlan_supplyPlan` {fieldName: 'supplyPlan'}]->(supplyPlan:`SupplyPlan`)
WHERE supplyPlan.id = '0804-01'
}
RETURN shipment;
NodeIndexSeek@neo4
so it should hit the index we created
3. insert data of Shipment & Supply including node and edge
CREATE (shipment:Shipment {type: 'Shipment', tenantId: "0804", id:"0804-shipment-1"});
CREATE (supplyPlan:SupplyPlan {type: 'SupplyPlan', tenantId: "0804", id:"0804-01"});
MATCH (shipment:Shipment),(supplyPlan:SupplyPlan)
WHERE shipment.id = "0804-shipment-1" AND supplyPlan.id = "0804-01"
CREATE (shipment)-[r:`Shipment_SupplyPlan_supplyPlan` {fieldName: 'supplyPlan'}]->(supplyPlan)
RETURN type(r), r.fieldName;
4. re-execute the explain of query again
We found it shows the
NodeByLabelScan@neo4j
It did not hit the index
5. not use exists in where condition and try a simple query
I think using exists in where condition may be a little different, so i try a simple query with match relation pattern:
explain MATCH (shipment:`Shipment` {tenantId: '0804', type: 'Shipment'})-[:`Shipment_SupplyPlan_supplyPlan` {fieldName: 'supplyPlan'}]->(supplyPlan:`SupplyPlan`)
WHERE supplyPlan.id = '0804-01'
RETURN shipment;
We found it showed the
NodeIndexSeek@neo4
again.
Conclusion & Question:
After inserting data, why the query with exists in where condition, can not hit the index?
Thanks so much~
08-20-2021 04:26 AM
Hi @1033516561 !
Do you have a script to create a dump db of your use case?
It may help me in order to quickly test this.
H
EDIT:
I tried your queries in the same order, I always get the NodeIndexSeek execution.
H
08-23-2021 07:43 PM
Hi, @Bennu
Which server version did you try in the above test?
I tried again in totally new 4.3.3 neo4j, with the default config and followed the steps above. It always can not hit the index in the second EXPLAIN(the first explain can hit, but after inserting the data, EXPLAIN can not hit the index)
All the sessions of the conference are now available online