Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Index scan cost does not account for disk fetch cost correctly #21892

Closed
1 task done
gauravk-in opened this issue Apr 9, 2024 · 0 comments
Closed
1 task done
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue

Comments

@gauravk-in
Copy link
Contributor

gauravk-in commented Apr 9, 2024

Jira Link: DB-10792

Description

The following query is from cost-validation benchmark in TAQO.

create table t100000 (c1 int, c2 int not null, c3 int, c4 int, c5 int, c6 int, v char(1024), primary key (c1 asc));
create index t100000_c2_c4 on t100000 (c2 asc) include (c4);
create index t100000_c2_c4v on t100000 (c2 asc) include (c4, v);

insert into t100000
  select i, i2,
         nullif((i3+4)/5, (100000+4)/5),
         nullif((i4+9)/10, (100000+9)/10),
         i5,
         nullif((i6+99)/100, (100000+99)/100),
         lpad(sha512(i5::text::bytea)||sha512(i::text::bytea)::text, 1024, '-')
    from (
      select i,
          row_number() over (order by random()) i2,
          row_number() over (order by random() + 1) i3,
          row_number() over (order by random() + 2) i4,
          row_number() over (order by random() + 3) i5,
          row_number() over (order by random() + 4) i6
        from generate_series(1, 100000) i
    ) v order by 1;

ANALYZE t100000;

-- The following queries have the same cost, even though the t100000_c2_c4v has included column v which is 8KB wide.

/*+ IndexOnlyScan(t100000_c2_c4) */ explain SELECT avg(c4) FROM t100000;
/*+ IndexOnlyScan(t100000_c2_c4v) */ explain SELECT avg(c4) FROM t100000;

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@gauravk-in gauravk-in added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels Apr 9, 2024
@gauravk-in gauravk-in self-assigned this Apr 9, 2024
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Apr 9, 2024
gauravk-in added a commit that referenced this issue Apr 19, 2024
Summary:
The YB base scans cost model calculates the index tuple width to estimate the
cost of fetching the index from the disk to memory. This change fixes a bug in
the index tuple width calculation.
Jira: DB-10792

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTAQO#testPgRegressTAQO'

Reviewers: tverona, tnayak

Reviewed By: tnayak

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D33947
gauravk-in added a commit that referenced this issue May 14, 2024
…ost model

Summary:
Original commit: fa7c8bb / D33947
The YB base scans cost model calculates the index tuple width to estimate the
cost of fetching the index from the disk to memory. This change fixes a bug in
the index tuple width calculation.
Jira: DB-10792

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTAQO#testPgRegressTAQO'

Reviewers: tverona, tnayak, telgersma

Reviewed By: telgersma

Subscribers: yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D35028
svarnau pushed a commit that referenced this issue May 25, 2024
Summary:
The YB base scans cost model calculates the index tuple width to estimate the
cost of fetching the index from the disk to memory. This change fixes a bug in
the index tuple width calculation.
Jira: DB-10792

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTAQO#testPgRegressTAQO'

Reviewers: tverona, tnayak

Reviewed By: tnayak

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D33947
svarnau pushed a commit that referenced this issue May 29, 2024
…ost model

Summary:
Original commit: fa7c8bb / D33947
The YB base scans cost model calculates the index tuple width to estimate the
cost of fetching the index from the disk to memory. This change fixes a bug in
the index tuple width calculation.
Jira: DB-10792

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTAQO#testPgRegressTAQO'

Reviewers: tverona, tnayak, telgersma

Reviewed By: telgersma

Subscribers: yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D35028
@yugabyte-ci yugabyte-ci removed the status/awaiting-triage Issue awaiting triage label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

2 participants