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

Wrong indexed query estimates exceed more than double the actual index entries

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Won't Fix
    • 1.1.8
    • None
    • query
    • None

    Description

      The ApproximateCounter.adjustCountSync public method that is used by the indexing engine will sometimes produce very unrealistic cost estimates.

      The problem is that it can produce an estimated cost that exceeds the estimated cost of the full traversal query, thus causing the index to be bypassed altogether, resulting in a full traversal rather than the use of the existing index.

      Problem resides in the way the property counts are updated:

      • The count property update goes through if two randoms are equal to zero: random(100) and random( {1, 2, 4, 8, 16, ...}

        ).

      • Same static pseudo random generator for all invocations.

      Even if #1 might seem improbable, it is statistically possible to reach a very high count with only a handful of invocations.

      In practice I've found that running 100 tests with 1000 invocations if the adjustCountSync method will yield costs exceeding value 2000 in 4-10% of the tests. Attaching a patch for ApproximateCounterTest with this test case.

      Attachments

        1. OAK-2725-test.patch
          2 kB
          Florin Iordache

        Issue Links

          Activity

            People

              Unassigned Unassigned
              florin.iordache Florin Iordache
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: