Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-9522

Index cost estimation: prefer union query with path restriction

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.42.0, 1.22.9
    • None

    Description

      If there is a query of this form with an index that supports path restrictions (evaluatePathRestrictions = true):

      select * from [nt:base] where [indexedProperty] = x 
      and (issamenode('/content') or isdescendantnode('/content'))
      

      then the path restriction isn't used in the index.
      This is unfortunate, because the index returns a lot more results, and the query engine will have to check if the path matches the condition.

      How this works: the query engine creates two possible queries:

      • plan a: one with just the [indexedProperty] = x condition, and no path restriction
      • plan b: a union query, where one side uses issamenode and the other side uses isdescendantnode.

      The index will return the same cost no matter if a path condition is there or not. And that's why the query engine will pick plan a: because the cost of the union query is higher.

      The index should return a lower cost if there is a path restriction. (Right now the query engine will reduce the cost if there is a path restriction, but that's not sufficient for this case).

      Attachments

        Issue Links

          Activity

            People

              thomasm Thomas Mueller
              thomasm Thomas Mueller
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: