-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: DB-scope virtual tables are slow despite a small DB #90115
Description
Is your feature request related to a problem? Please describe.
CockroachDB offers per-database metadata schemas information_schema and pg_catalog. The tables in these schemas are implemented "virtually"; instead of being real tables, we run some code over the internal metadata structures to generate the output. Today, in order to populate the correct set of descriptors, we unconditionally fetch all descriptors. In cases where individual databases are not large, but the total number of descriptors is large, virtual tables are shockingly slow. Importantly, these virtual tables don't need to look at most of these descriptors.
Describe the solution you'd like
We can avoid looking at the unwanted descriptors by performing a lookup first against the namespace table and then fetching the descriptors in the database.
Additional context
This approach won't help with cases like #83626 where individual schemas or databases have large numbers of objects.
Epic: CRDB-20865
Jira issue: CRDB-20592