forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33350: sql: point spans should never include interleaves r=jordanlewis a=jordanlewis Closes cockroachdb#33347. Closes cockroachdb#33326. Closes cockroachdb#33330. Previously, many sql processors that needed to generate spans for key lookups unconditionally used the PrefixEnd method on the key to look up to get the end of the keyspan. While correct, this generated span is wide enough to contain all child interleaves of a table on that key, if they exist. This is very bad for performance, causing "point scans" to accidentally need to scan through an entire interleaves if it exists. Now, code is adjusted to use spans that are bounded on the right by the interleave marker appended to the start key, if the index to look up in is unique and fully specified. Note that the condition chosen is broader than strictly necessary - we only insert interleaves today into primary indexes, and we could tighten the condition to only emit an interleave marker if the index does in fact have interleaves - but keeping the condition simple makes things easier to test and provides a modicum of assurance that this hairy code won't have to change again if we decide to permit interleaving tables or indexes into other unique, non primary indexes later. New helper methods were introduced that permit retrieval of the key span for a set of key values, and not just the key itself, in the hopes that future code won't commit the same sins. ``` name old time/op new time/op delta SQL/Cockroach/InterleavedFK/count=1-8 790µs ± 9% 515µs ± 8% -34.77% (p=0.000 n=10+10) SQL/Cockroach/InterleavedFK/count=10-8 6.53ms ± 7% 1.32ms ± 5% -79.79% (p=0.000 n=10+10) SQL/Cockroach/InterleavedFK/count=100-8 65.1ms ±10% 9.7ms ±14% -85.16% (p=0.000 n=10+10) SQL/Cockroach/InterleavedFK/count=1000-8 565ms ± 8% 102ms ±11% -81.99% (p=0.000 n=10+10) name old alloc/op new alloc/op delta SQL/Cockroach/InterleavedFK/count=1-8 158kB ± 2% 54kB ± 6% -65.89% (p=0.000 n=10+10) SQL/Cockroach/InterleavedFK/count=10-8 2.72MB ± 1% 0.14MB ± 1% -94.88% (p=0.000 n=10+9) SQL/Cockroach/InterleavedFK/count=100-8 26.8MB ± 1% 1.0MB ± 7% -96.17% (p=0.000 n=10+8) SQL/Cockroach/InterleavedFK/count=1000-8 222MB ± 1% 11MB ± 6% -94.95% (p=0.000 n=10+9) name old allocs/op new allocs/op delta SQL/Cockroach/InterleavedFK/count=1-8 515 ± 2% 508 ± 3% ~ (p=0.195 n=10+10) SQL/Cockroach/InterleavedFK/count=10-8 1.64k ±20% 1.33k ± 1% -18.59% (p=0.000 n=10+9) SQL/Cockroach/InterleavedFK/count=100-8 14.2k ±12% 10.0k ±15% -29.25% (p=0.000 n=10+9) SQL/Cockroach/InterleavedFK/count=1000-8 129k ±16% 102k ± 7% -21.07% (p=0.000 n=10+9) ``` Release note (performance improvement): index joins, lookup joins, foreign key checks, cascade scans, zig zag joins, and upserts no longer needlessly scan over child interleaved tables when searching for keys. Co-authored-by: Jordan Lewis <[email protected]>
- Loading branch information
Showing
15 changed files
with
349 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.