Skip to content

intersectionEstimate multiplies Infinity into the incoming-row hint used by filter index switching #3726

Open

Description

@kriszyp

Problem

mapConditionsToFilters (resources/search.ts) narrows estimatedIncomingCount after each filter with intersectionEstimate(store, condition.estimated_count, estimatedIncomingCount). A filter-only condition (contains, ends_with, ne <value>, negated) estimates Infinity, so the hint becomes Infinity for every later filter in the chain.

filterByType uses the hint to decide when to switch a filter to an index lookup: estimatedIncomingCount > 3 and (misses / filteredSoFar) * estimatedIncomingCount > thresholdRemainingMisses. With Infinity it switches on the first miss, so a filter that follows a filter-only condition builds its id set from the index earlier than the real estimates would justify.

The AND estimate in estimateCondition already skips non-finite legs (Keep an AND group's estimate finite when a sibling condition is filter-only). The same rule here would keep the hint at its last finite value.

Notes

Performance heuristic only; no result changes. Changing it moves when lookups switch, so measure a filter chain after a filter-only condition before and after.

Review-Deferral: c98b870701ea83f7 severity=nit category=performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    P3

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions