-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: make hashed OIDs identifiable for optimal virtual indexes #103399
Conversation
Due to the recent increase in table sizes for builtins, certain tables like pg_class are now joining on hundreds of rows. While these tables contain virtual indexes, these virtual indexes will return to full table scan if an OID is not found. That's because they have no way of knowing if the OID is a hashed index or a descriptor ID. To address this, these changes are going to alter OID hashing, so that OID hashes are generated at values greater than CockroachPredefinedOIDMax. This then allows virtual indexes to avoid full table scans if the value matched is not found (i.e. if its a builtin function reference). Fixes: cockroachdb#102851 Release note (sql change): OID generation for pg_catalog has changed. For example column, index and constraint OID's will have different values. Relation, type and function OID's are unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@chengxiong-ruan TFTR! bors r+ |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from a5ad914 to blathers/backport-release-23.1-103399: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 23.1.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to write an rttanalysis test that shows how this helps?
@@ -4740,6 +4747,10 @@ func (h oidHasher) writeTypeTag(tag oidTypeTag) { | |||
|
|||
func (h oidHasher) getOid() *tree.DOid { | |||
i := h.h.Sum32() | |||
// Ensure generated OID hashes are above the pre-defined max limit, | |||
// this gives us a cheap filter. | |||
i = i%(math.MaxUint32-oidext.CockroachPredefinedOIDMax) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like it would be quicker to do
if i < oidext.CockroachPredefinedOIDMax {
i += oidext.CockroachPredefinedOIDMax
}
since it's fewer arithmetic operations. this would have also reduced the size of the diff in tests. but more importantly, it's easier to understand what the code is doing.
blathers backport 23.1 |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from a5ad914 to blathers/backport-release-23.1-103399: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 23.1 failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
blathers backport 23.1 |
1 similar comment
blathers backport 23.1 |
blathers backport 23.1 |
101485: roachtest: add 32TB, 400 incremental restore roachtest r=rhu713 a=rhu713 Add a 32TB, 400 incremental restore roachtest. The restore in this roachtest has been verified to fail on v22.2.7 due to OOM, but should succeed for v23.1+ due to the slim manifest changes. Release note: None 103487: ccl/sqlproxyccl: default tenants to both public and private connectivities r=pjtatlow a=jaylim-crl Previously, we had introduced 3 states (ALLOW_NONE, ALLOW_PUBLIC, and ALLOW_PRIVATE) with the intention that ALLOW_NONE would be useful. Thinking about it further, it does not make sense for a cluster to support ALLOW_NONE (i.e. what would that actually mean?). This commit updates the connectivity types to support ALLOW_ALL, ALLOW_PUBLIC_ONLY, and ALLOW_PRIVATE_ONLY. By default, ConnectivityType=0, which maps to ALLOW_ALL. Release note: None Epic: none 103540: roachtest: fix drain test to account for jobs_wait r=rafiss a=rafiss fixes #103396 The change in e8b075b made this test start failing. Since we don't need this test to do anything with jobs, we can fix it by turning off the jobs waiting period. This also fixes the node drain CLI command to be aware of jobs_wait. Release note: None 103547: sql: use a simpler method for clamping OID hash r=rafiss a=rafiss This reduces the amount of OID churn and also is simpler, so might perform better. Having less churn is better for backports. informs #103399 Release note: None Co-authored-by: Rui Hu <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: Rafi Shamim <[email protected]>
Due to the recent increase in table sizes for builtins, certain tables like pg_class are now joining on hundreds of rows. While these tables contain virtual indexes, these virtual indexes will return to full table scan if an OID is not found. That's because they have no way of knowing if the OID is a hashed index or a descriptor ID. To address this, these changes are going to alter OID hashing, so that OID hashes are generated at values greater than CockroachPredefinedOIDMax. This then allows virtual indexes to avoid full table scans if the value matched is not found (i.e. if its a builtin function reference).
Fixes: #102851
Release note (sql change): OID generation for pg_catalog has changed. For example column, index and constraint OID's will have different values. Relation, type and function OID's are unchanged.
Benchmark difference after this change: