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

sql: slow metadata queries after upgrading FKs from 19.1 to 19.2 #48517

Closed
thoszhang opened this issue May 7, 2020 · 5 comments
Closed

sql: slow metadata queries after upgrading FKs from 19.1 to 19.2 #48517

thoszhang opened this issue May 7, 2020 · 5 comments
Labels
C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@thoszhang
Copy link
Contributor

thoszhang commented May 7, 2020

In 19.2, we started upgrading table descriptors to the new foreign key representation. Whenever a table descriptor is fetched from KV, if the foreign key representation hasn't already been upgraded, we also fetch all the tables that have foreign key relationships with that table.

We've seen a case where a geodistributed cluster, after being upgraded to 19.2, now takes ~30 seconds to return results from queries on information_schema.tables because of how long it takes to fetch all the FK dependencies for every table. This can cause problems for ORMs and migration tools which rely on these introspection queries. Furthermore, this state persists until the state of the table descriptor with the new foreign key representation has been written back to disk, which only happens when there's a schema change.

A workaround for this is to do some relatively trivial schema change (like GRANT for a dummy user) on every single table in the cluster, but this isn't a very satisfactory solution because it requires manual intervention.

Jira issue: CRDB-4317

@thoszhang thoszhang added the C-performance Perf of queries or internals. Solution not expected to change functional behavior. label May 7, 2020
@thoszhang
Copy link
Contributor Author

thoszhang commented May 7, 2020

cc @jordanlewis

It seems like filter pushdown for virtual tables would mitigate this; right now, every single table with un-upgraded FKs contributes to the problem. Also, hopefully by 21.1 we'll have a migration to take care of the old tables once and for all.

I don't have any good ideas for shorter-term solutions at the moment. I think any solution that we would potentially backport to 19.2/20.1 would have to be quite extensive (e.g., better caching, some background task that upgrades descriptors), so we'd only do it if the impact were determined to be high.

@rohany
Copy link
Contributor

rohany commented May 7, 2020

I think it's possible for us to write a sqlmigration that upgrades out of date foreign keys (if any exist) now right?

@thoszhang
Copy link
Contributor Author

In theory, yeah, but I think we're trying to avoid blocking starting a new node on a migration that takes O(tables) time to run.

Copy link
Member

Vtable pushdown will be available in 20.2. We could consider backporting some of it if necessary.

@thoszhang
Copy link
Contributor Author

We're not going to do anything about this beyond having the planned long-running migration to get rid of old-style descriptors, tracked in ##48743.

@jlinder jlinder added the T-sql-schema-deprecated Use T-sql-foundations instead label Jun 16, 2021
@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

5 participants