-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#26235] YSQL: Index scan cost model should expect disk blocks are fe…
…tched sequentially for primary index scan Summary: In the cost model, we try to predict the order in which the disk blocks need to be fetched. In case of a secondary index scan, we assume that the disk blocksfor primary table will be fetched in a random order. But for a primary index scan, we must assume that the disk blocks are fetched in sequential order. Before this change, the index scan was being costed higher than a sequential scan for the following example. With this change, the index scan is cheaper. ``` CREATE TABLE t1 (a INT, PRIMARY KEY (a ASC)); INSERT INTO t1 SELECT s FROM generate_series(1, 10) s; ANALYZE t1; SET yb_enable_base_scans_cost_model = ON; yugabyte=# explain select * from t1 where a < 5; QUERY PLAN -------------------------------------------------------------------- Index Scan using t1_pkey on t1 (cost=10.00..31.21 rows=3 width=4) Index Cond: (a < 5) (2 rows) yugabyte=# /*+ SeqScan(t1) */ explain select * from t1 where a < 5; QUERY PLAN ---------------------------------------------------- Seq Scan on t1 (cost=10.00..31.61 rows=3 width=4) Storage Filter: (a < 5) (2 rows) ``` Jira: DB-15582 Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPlanner' Reviewers: mtakahara, amartsinchyk Reviewed By: mtakahara Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D42188
- Loading branch information
1 parent
9abf529
commit cc3c7c6
Showing
5 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters