I have tried profiling the following simple cypher query:
profile match (a:A)-[r:R]->(b:B) return *
The plan is as follows:
- NodeByLabelScan. According to neo4j statistics, it is clear the first step, NodeByLabelScan cardinality can be estimated with an accurate value.
- ExpandAll. The count of nodes from a specific label through a given edge label is stored as well. So this cardinality is accurate as well.
- Filter. In this query, the estimation is accurate as well. The actual cardinality is 1 as well. But I tried other queries, the estimation is not accurate. I am curious how the filter step cardinality is estimated.
It will be helpful you can point me to the source code location as well.