Skip to content

tree: make int::regtype::text O(1)#40267

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jordanlewis:improve-type-cast
Aug 28, 2019
Merged

tree: make int::regtype::text O(1)#40267
craig[bot] merged 1 commit intocockroachdb:masterfrom
jordanlewis:improve-type-cast

Conversation

@jordanlewis
Copy link
Copy Markdown
Member

Previously, casting an integer to a regtype and then text (which turns a
type OID into the string of its corresponding type) would run a select
over pg_type to figure out the answer, which under the hood
materializes all of the types into a table and filters, an O(n)
operation. This is silly because we already have a static lookup table
for this info. Use it.

This commonly shows up in visualization tools as O(n^2), since people
tend to run one of these casts once per type. So this improves metadata
query performance significantly.

Release note: None

@jordanlewis jordanlewis requested a review from a team August 27, 2019 21:55
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Previously, casting an integer to a regtype and then text (which turns a
type OID into the string of its corresponding type) would run a select
over pg_type to figure out the answer, which under the hood
materializes all of the types into a table and filters, an O(n)
operation. This is silly because we already have a static lookup table
for this info. Use it.

This commonly shows up in visualization tools as O(n^2), since people
tend to run one of these casts once per type. So this improves metadata
query performance significantly.

Release note: None
@jordanlewis jordanlewis requested a review from knz August 28, 2019 14:19
Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

wow nice catch.

@jordanlewis
Copy link
Copy Markdown
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Aug 28, 2019
40234: storage: test atomic replication changes r=nvanbenschoten a=tbg

This PR adds a number of tests that focus on the interaction between the various
queues and joint configurations.

We don't flip the switch yet since adding/removing only learners does not work
yet via the joint path. This isn't something we need per se, but it's an
annoying restriction to keep in mind and work around if it does happen. Tracked
in
#12768 (comment).

40267: tree: make int::regtype::text O(1) r=jordanlewis a=jordanlewis

Previously, casting an integer to a regtype and then text (which turns a
type OID into the string of its corresponding type) would run a select
over pg_type to figure out the answer, which under the hood
materializes all of the types into a table and filters, an O(n)
operation. This is silly because we already have a static lookup table
for this info. Use it.

This commonly shows up in visualization tools as O(n^2), since people
tend to run one of these casts once per type. So this improves metadata
query performance significantly.

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 28, 2019

Build succeeded

@craig craig bot merged commit 79226f6 into cockroachdb:master Aug 28, 2019
@jordanlewis jordanlewis deleted the improve-type-cast branch August 28, 2019 15:18
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.

3 participants