Skip to content

builtins: implement *_description with UDFs#95090

Merged
rafiss merged 1 commit intocockroachdb:masterfrom
rafiss:obj-description-udf
Jan 11, 2023
Merged

builtins: implement *_description with UDFs#95090
rafiss merged 1 commit intocockroachdb:masterfrom
rafiss:obj-description-udf

Conversation

@rafiss
Copy link
Collaborator

@rafiss rafiss commented Jan 11, 2023

fixes #95068
fixes #87947

These builtin functions can be implemented using UDFs, which avoids using the internal executor, and improves the amount of duplicated work.

The new benchmarks have fewer roundtrips and no longer scale based on entity count:

  • django_table_introspection_1_table: 8 -> 5
  • django_table_introspection_8_tables: 15 -> 5

Release note: None

@rafiss rafiss requested review from a team, ZhouXing19, jordanlewis and mgartner January 11, 2023 18:14
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss rafiss force-pushed the obj-description-udf branch from 081173d to 100f31f Compare January 11, 2023 18:20
WHERE objoid = $1
AND objsubid = 0
AND classoid = CASE $2
WHEN 'pg_class' THEN %[1]d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do this using a join on pg_class rather than a hardcoded case/when list, unless there's a strong reason to do it this way? I guess it's maybe more efficient to do it this way - but will there be any compat issues with this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what did you have in mind? do you mean AND classoid = $2::regclass::oid? i think that will have a performance penalty, but i'll check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the roundtrips were not affected by the JOIN approach, nor was the latency in my local manual testing, so i'll do it that way

@rafiss rafiss force-pushed the obj-description-udf branch 2 times, most recently from 57aed38 to 9d12964 Compare January 11, 2023 19:08
These builtin functions can be implemented using UDFs, which avoids
using the internal executor, and dramatically improves the amount of
duplicated work.

The new benchmarks have fewer roundtrips and no longer scale based on entity count:
- django_table_introspection_1_table: 8 -> 5
- django_table_introspection_8_tables: 15 -> 5

Release note: None
@rafiss rafiss force-pushed the obj-description-udf branch from 9d12964 to b12398a Compare January 11, 2023 20:05
@rafiss rafiss requested a review from a team as a code owner January 11, 2023 20:05
@rafiss rafiss merged commit 95e062f into cockroachdb:master Jan 11, 2023
@rafiss rafiss deleted the obj-description-udf branch January 11, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: pg_catalog.obj_description is very slow pg_catalog.col_description is very slow

3 participants