Description
Currently, the P2 index (and therefore also the NodeType index) count the number of nodes up to configurable number of nodes. To improve the query plan, the number of returned nodes should be estimated. There are multiple ways, for example
- Using stored statistics (store the number of child nodes for each index lookup). This is very accurate, but requires to update the statistic from time to time, and this is slow and therefore probably needs to run in background process
- Read a number of nodes (as it's done now), and then estimate the number of nodes for the lookup based on the average depth and width of the matches (the deeper the tree, the more expected matches). This is somewhat accurate, and does not require too much code.