Skip to content

sql: pg_catalog.obj_description is very slow #95068

@timgraham

Description

@timgraham

Describe the problem

A new feature in Django 4.2 (to be released in April) adds obj_description to an introspection query. The new query takes on the order of ten seconds when running Django's test suite.

To Reproduce

SELECT
    c.relname,
    CASE
        WHEN c.relispartition THEN 'p'
        WHEN c.relkind IN ('m', 'v') THEN 'v'
        ELSE 't'
    END,
    obj_description(c.oid)
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
    AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
    AND pg_catalog.pg_table_is_visible(c.oid)

Environment:

  • CockroachDB version v22.2.2 and v22.1.13. (I haven't been unable to test nightly due to another slowdown).

Additional context

The run time of Django's test suite went from ~1 hour to ~7 or more hours.

#87947 may be related, however, Django's introspection query that uses col_description doesn't appear to be slow.

Jira issue: CRDB-23305

Epic CRDB-23454

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an owner

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions