Hi, On Wed, Jun 18, 2014 at 4:26 AM, Tommaso Teofili <tommaso.teof...@gmail.com> wrote: > should we just return the number of estimated entries for the cost?
Yes, that's what I think the contract should be. > My other concern on this point is that it's not granted, in my opinion, > that the index returning less entries would be the faster. The key concern here isn't the performance of the index, but the overall performance of the query. If an index returns n paths for a given query, then the amount of work done by the query engine will be O(n) as it needs to look up each path and double-check the constraints on those nodes (or O(n log n) if it also needs to sort the results). Since I don't expect any reasonable index to perform worse than O(n), returning n as the cost estimate seems like the best thing to do. On a related note, I tend to disagree with the additional cost factors introduced in AdvancedQueryIndex/IndexPlan. In practically all cases the index lookups will be asymptotically faster than looking up all the paths returned by the index. Thus I don't think there is value in trying to make detailed estimates about the cost of the index lookup. BR, Jukka Zitting