-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
sql: improve the SHOW TABLES query to avoid reading stats when unused #59838
base: master
Are you sure you want to change the base?
sql: improve the SHOW TABLES query to avoid reading stats when unused #59838
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @rafiss)
LEFT JOIN crdb_internal.table_row_statistics AS s ON (s.table_id = pc.oid::INT8) | ||
LEFT JOIN | ||
( | ||
SELECT DISTINCT ON (table_id) table_id, estimated_row_count FROM crdb_internal.table_row_statistics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity, do we achieve the same thing by adding a crdb_internal.table_row_statistics(table_id)
virtual index? i forget if virtual indexes are required to be unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think they are unique indexes.
ah i misread the intention of this. do you mind backporting it too? thanks! |
There is a distinct relationship between tables and row statistics which was previously not stated explicitly in the query and thus, the optimizer was unable to eliminate the join against the statistics table when the `estimated_row_count` column was not used. Release note (performance improvement): Queries which use `SHOW TABLES` but do not utilize the `estimated_row_count` column no longer need to look up the table statistics.
ce0f4c3
to
9773f4b
Compare
There is a distinct relationship between tables and row statistics which
was previously not stated explicitly in the query and thus, the optimizer
was unable to eliminate the join against the statistics table when the
estimated_row_count
column was not used.Touches #58189.
Release note (performance improvement): Queries which use
SHOW TABLES
butdo not utilize the
estimated_row_count
column no longer need to look upthe table statistics.