-
[OPIK-6311] [BE] perf: push Top-N filter into dataset_items_aggr_resolved CTE (#6559)
发布于
2026-04-30 14:57:35 +00:00 - [OPIK-6311] [BE] perf: push Top-N filter into dataset_items_aggr_resolved CTE
Extends push_top_limit so it also activates for the default-sort case
(no sortingFields, no filters, no search) used by the experiment compare
page. In that case the Top-N CTE is defined before
dataset_items_aggr_resolved, and dataset_item_id IN (top_dataset_items)
is pushed into the dedup CTE so the existing bloom_filter / minmax skip
indexes on dataset_item_versions and experiment_item_aggregates can prune
granules.When sorting requires the dataset-items join (push_top_needs_div), keep
the previous CTE order to avoid forward references.Implements OPIK-6311.
- [OPIK-6311] [BE] fix: gate push-top-limit off when filters or search are present
The Top-N CTE selects items by sort BEFORE the outer query applies
filters and search. When filters or search are active the outer scan
strips items from the top-N, which silently returns short pages even
though additional matches exist below the cutoff.Tightens the pushTopLimit gate to require !hasFilters && !hasSearch
across both the explicit-sort and default-sort branches. The
default-sort branch already had this guard; this lifts it to also
cover the explicit-sort path that has been latent since the original
push-top-limit work.Adds a regression test in ExperimentAggregatesIntegrationTest that
reproduces the bug: items with deterministic durations 10s, 20s,
... per index; sorted by duration ASC with filter duration > 30000ms;
page size 2. Without the fix, the unfiltered top-2 picks the lowest
durations which then fail the filter, returning an empty page even
though items at index 3+ match. With the fix, the raw-branch result is
preserved post-aggregation. Verified via assertDatasetItemsWithExperimentItems
for full-object equality.下载附件