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: pg_catalog.obj_description is very slow #95068

Closed
timgraham opened this issue Jan 11, 2023 · 2 comments · Fixed by #95090
Closed

sql: pg_catalog.obj_description is very slow #95068

timgraham opened this issue Jan 11, 2023 · 2 comments · Fixed by #95090
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner

Comments

@timgraham
Copy link
Contributor

timgraham commented Jan 11, 2023

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

@timgraham timgraham added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jan 11, 2023
@blathers-crl
Copy link

blathers-crl bot commented Jan 11, 2023

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I have CC'd a few people who may be able to assist you:

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Jan 11, 2023
@rafiss rafiss added this to Triage in SQL Sessions - Deprecated via automation Jan 11, 2023
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Jan 11, 2023
@rafiss
Copy link
Collaborator

rafiss commented Jan 11, 2023

Thanks for the report! We should be able to improve the performance on master, but it depends on other changes that might make it impossible to improve in v22.2 and v22.1.

Just for your awareness, the 1-parameter form of obj_description is deprecated in PostgreSQL. A similar concern applies to CockroachDB, though we haven't documented this. https://www.postgresql.org/docs/15/functions-info.html

obj_description ( object oid ) → text

Returns the comment for a database object specified by its OID alone. This is deprecated since there is no guarantee that OIDs are unique across different system catalogs; therefore, the wrong comment might be returned.

@rafiss rafiss self-assigned this Jan 11, 2023
rafiss added a commit that referenced this issue Jan 11, 2023
SQL Sessions - Deprecated automation moved this from Triage to Done Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants