Skip to content

sql: DB-scope virtual tables are slow despite a small DB #90115

@ajwerner

Description

@ajwerner

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

Metadata

Metadata

Assignees

Labels

C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions