You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2026/10/13 11:08:25 UTC

[L] Change in asterixdb[master]: [ASTERIXDB-3955][COMP] Fix CBO cost of a pushed LIMIT

From Rithwik Koul <ri...@couchbase.com>:

Hello Anon. E. Moose #1000171, Jenkins, 

I'd like you to reexamine a change. Please visit

    https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/22002?usp=email

to look at the new patch set (#14).

The following approvals got outdated and were removed:
Contrib+1 by Anon. E. Moose #1000171, Integration-Tests+1 by Jenkins


Change subject: [ASTERIXDB-3955][COMP] Fix CBO cost of a pushed LIMIT
......................................................................

[ASTERIXDB-3955][COMP] Fix CBO cost of a pushed LIMIT

The CBO costed every operator of a plan as if it stopped at a pushed
LIMIT. A limit is pushed only into a primary-index search, so a
secondary-index search still returns every match, and the primary-key
sort after it is blocking. An index plan therefore looked near-constant
and won even when a scan that stops after a few rows was far cheaper.

A primary-index search returns the records itself, so it is no longer
charged a primary-key sort and fetch.

Measured against an index plan, a scan that a limit stops early still
runs several times slower than the rows it reads suggest, so it is
costed as reading eight times further, though never more than a full
scan. Without that weight it displaced index plans that were faster on
selective predicates with large limits.

Ext-ref: MB-70486
Change-Id: Id437d35c7c3e3f9624076464d196518da823400c
---
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/cost/CostMethods.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/cost/ICostMethods.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushLimitIntoOrderByRule.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinEnum.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/JoinNode.java
M asterixdb/asterix-app/src/test/resources/runtimets/results/cardinality-estimation/single-collection-queries/single-collection-queries.10.plan
M asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/limit/push-limit-to-primary-lookup-select/push-limit-to-primary-lookup-select.3.plan
M asterixdb/asterix-app/src/test/resources/runtimets/results_cloud/cardinality-estimation/single-collection-queries/single-collection-queries.10.plan
M asterixdb/asterix-app/src/test/resources/runtimets/results_column/cardinality-estimation/single-collection-queries/single-collection-queries.10.plan
M asterixdb/asterix-app/src/test/resources/runtimets/results_ncservice/cardinality-estimation/single-collection-queries/single-collection-queries.10.plan
10 files changed, 160 insertions(+), 101 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/02/22002/14
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/22002?usp=email
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Id437d35c7c3e3f9624076464d196518da823400c
Gerrit-Change-Number: 22002
Gerrit-PatchSet: 14
Gerrit-Owner: Rithwik Koul <ri...@couchbase.com>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Rithwik Koul <ri...@couchbase.com>