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

opt: Poor row count estimate for join with multiple conditions #38735

Open
andy-kimball opened this issue Jul 8, 2019 · 3 comments
Open

opt: Poor row count estimate for join with multiple conditions #38735

andy-kimball opened this issue Jul 8, 2019 · 3 comments
Labels
A-sql-optimizer SQL logical planning and optimizations. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-queries SQL Queries Team
Projects

Comments

@andy-kimball
Copy link
Contributor

andy-kimball commented Jul 8, 2019

Using the TPC-H schema, I was running a query similar to the following:

explain (opt,types) select count(*) from partsupp, lineitem where ps_partkey = l_partkey AND ps_suppkey = l_suppkey;

EXPECTED: I expected the estimated number of rows returned by the join to be in the same ballpark as the actual number of rows.

ACTUAL: The estimated number of rows was only 2,429, even though the actual number of rows is 6,001,215.

This discrepancy seems to occur only when both join conditions are used together. Either one alone gives 4+ orders of magnitude of difference, which is surprising.

Epic CRDB-16930

Jira issue: CRDB-5612

Jira issue: CRDB-13896

@andy-kimball andy-kimball added this to Triage in BACKLOG, NO NEW ISSUES: SQL Optimizer via automation Jul 8, 2019
@awoods187 awoods187 added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Jul 9, 2019
@RaduBerinde RaduBerinde moved this from Triage to Plan enhancements (higher priority) in BACKLOG, NO NEW ISSUES: SQL Optimizer Apr 18, 2020
@github-actions
Copy link

github-actions bot commented Jun 4, 2021

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
5 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@rytaft rytaft added A-sql-optimizer SQL logical planning and optimizations. C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-queries SQL Queries Team and removed no-issue-activity labels Jun 7, 2021
@rytaft rytaft added this to Triage in SQL Queries via automation Jun 7, 2021
@rytaft rytaft moved this from Triage to 21.2 Medium Likelihood (60%) in SQL Queries Jun 7, 2021
@mgartner
Copy link
Collaborator

We've made many improvements to estimated row counts since this issue was created. Let's first check what the estimate row count is on the latest version and close this issue if it's more accurate.

@mgartner mgartner moved this from 22.1 Medium Likelihood (60%) to Triage in SQL Queries May 16, 2022
@mgartner mgartner moved this from Triage to 22.2 Release in SQL Queries May 31, 2022
@rytaft rytaft removed their assignment Jul 21, 2022
@rytaft rytaft moved this from 22.2 Release to Backlog in SQL Queries Jul 21, 2022
Copy link

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@mgartner mgartner removed this from Plan enhancements (higher priority) in BACKLOG, NO NEW ISSUES: SQL Optimizer Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-optimizer SQL logical planning and optimizations. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-queries SQL Queries Team
Projects
Status: Backlog
SQL Queries
Backlog (DO NOT ADD NEW ISSUES)
Development

No branches or pull requests

4 participants