Skip to content

opt: fix regression in many-columns-and-indexes microbenchmark#72136

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rytaft:fix-regression
Oct 29, 2021
Merged

opt: fix regression in many-columns-and-indexes microbenchmark#72136
craig[bot] merged 1 commit intocockroachdb:masterfrom
rytaft:fix-regression

Conversation

@rytaft
Copy link
Copy Markdown
Collaborator

@rytaft rytaft commented Oct 29, 2021

This commit fixes a regression that was due to unnecessary computation
of interesting orderings. We now only compute interesting orderings
when it may be beneficial for planning purposes.

Fixes #72001

Release note (performance improvement): Fixed a performance regression
in planning that could occur for simple queries on schemas with a large
number of indexes.

@rytaft rytaft requested review from a team, cucaroach and mgartner October 29, 2021 02:15
@rytaft rytaft requested a review from a team as a code owner October 29, 2021 02:15
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

benchmarks:

name                                                                   old time/op    new time/op    delta
Phases/many-columns-and-indexes-b/Prepared/Explore-4                      813µs ± 1%     416µs ± 1%  -48.75%  (p=0.016 n=5+4)
Phases/many-columns-and-indexes-b/Prepared/ExecBuild-4                    833µs ± 6%     430µs ± 4%  -48.44%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/ExecBuild-4                      869µs ± 5%     464µs ± 9%  -46.63%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Simple/ExecBuild-4                      917µs ± 4%     494µs ± 2%  -46.15%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Simple/Explore-4                        896µs ± 1%     487µs ± 3%  -45.65%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Prepared/Explore-4                      795µs ± 1%     433µs ±12%  -45.55%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Prepared/ExecBuild-4                    804µs ± 1%     442µs ±20%  -45.08%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/Explore-4                        850µs ± 1%     480µs ±23%  -43.55%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/Parse-4                         12.9µs ± 1%    13.1µs ± 5%     ~     (p=0.310 n=5+5)
Phases/many-columns-and-indexes-a/Simple/OptBuildNoNorm-4                 289µs ± 1%     300µs ± 5%     ~     (p=0.056 n=5+5)
Phases/many-columns-and-indexes-a/Simple/OptBuildNorm-4                   296µs ± 2%     298µs ± 1%     ~     (p=0.730 n=5+4)
Phases/many-columns-and-indexes-a/Prepared/AssignPlaceholdersNoNorm-4     257µs ± 0%     272µs ±10%     ~     (p=0.111 n=4+5)
Phases/many-columns-and-indexes-a/Prepared/AssignPlaceholdersNorm-4       259µs ± 1%     277µs ±19%     ~     (p=0.222 n=5+5)
Phases/many-columns-and-indexes-b/Simple/Parse-4                         23.5µs ± 2%    24.1µs ± 3%     ~     (p=0.310 n=5+5)
Phases/many-columns-and-indexes-b/Simple/OptBuildNoNorm-4                 319µs ± 2%     324µs ± 4%     ~     (p=0.421 n=5+5)
Phases/many-columns-and-indexes-b/Simple/OptBuildNorm-4                   334µs ± 1%     333µs ± 2%     ~     (p=1.000 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/AssignPlaceholdersNoNorm-4     269µs ± 3%     266µs ± 1%     ~     (p=0.841 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/AssignPlaceholdersNorm-4       264µs ± 0%     266µs ± 1%     ~     (p=0.190 n=4+5)

name                                                                   old alloc/op   new alloc/op   delta
Phases/many-columns-and-indexes-a/Prepared/Explore-4                      159kB ± 0%       4kB ± 0%  -97.26%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Prepared/ExecBuild-4                    159kB ± 0%       5kB ± 0%  -96.85%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/Explore-4                      161kB ± 0%       6kB ± 0%  -95.99%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/ExecBuild-4                    162kB ± 0%       7kB ± 0%  -95.39%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/Explore-4                        171kB ± 0%      17kB ± 0%  -90.31%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/ExecBuild-4                      172kB ± 0%      17kB ± 0%  -89.96%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Simple/Explore-4                        178kB ± 0%      24kB ± 0%  -86.76%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Simple/ExecBuild-4                      179kB ± 0%      25kB ± 0%  -86.27%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/Parse-4                         2.48kB ± 0%    2.48kB ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Simple/OptBuildNoNorm-4                13.6kB ± 0%    13.6kB ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Simple/OptBuildNorm-4                  15.5kB ± 0%    15.5kB ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Prepared/AssignPlaceholdersNoNorm-4    3.30kB ± 0%    3.30kB ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Prepared/AssignPlaceholdersNorm-4      3.30kB ± 0%    3.30kB ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Simple/Parse-4                         3.71kB ± 0%    3.71kB ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Simple/OptBuildNoNorm-4                19.5kB ± 0%    19.5kB ± 0%     ~     (p=1.000 n=5+5)
Phases/many-columns-and-indexes-b/Simple/OptBuildNorm-4                  22.5kB ± 0%    22.5kB ± 0%     ~     (p=0.746 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/AssignPlaceholdersNoNorm-4    5.40kB ± 0%    5.40kB ± 0%     ~     (p=1.000 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/AssignPlaceholdersNorm-4      5.40kB ± 0%    5.40kB ± 0%     ~     (p=0.444 n=5+5)

name                                                                   old allocs/op  new allocs/op  delta
Phases/many-columns-and-indexes-a/Prepared/Explore-4                        277 ± 0%        23 ± 0%  -91.70%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Prepared/ExecBuild-4                      288 ± 0%        34 ± 0%  -88.19%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/Explore-4                        292 ± 0%        38 ± 0%  -86.99%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Prepared/ExecBuild-4                      307 ± 0%        53 ± 0%  -82.74%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/Explore-4                          325 ± 0%        71 ± 0%  -78.15%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/ExecBuild-4                        336 ± 0%        82 ± 0%  -75.60%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Simple/Explore-4                          384 ± 0%       130 ± 0%  -66.15%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-b/Simple/ExecBuild-4                        399 ± 0%       145 ± 0%  -63.66%  (p=0.008 n=5+5)
Phases/many-columns-and-indexes-a/Simple/Parse-4                           21.0 ± 0%      21.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Simple/OptBuildNoNorm-4                  62.0 ± 0%      62.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Simple/OptBuildNorm-4                    69.0 ± 0%      69.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Prepared/AssignPlaceholdersNoNorm-4      21.0 ± 0%      21.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-a/Prepared/AssignPlaceholdersNorm-4        21.0 ± 0%      21.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Simple/Parse-4                           30.0 ± 0%      30.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Simple/OptBuildNoNorm-4                   109 ± 0%       109 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Simple/OptBuildNorm-4                     128 ± 0%       128 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Prepared/AssignPlaceholdersNoNorm-4      36.0 ± 0%      36.0 ± 0%     ~     (all equal)
Phases/many-columns-and-indexes-b/Prepared/AssignPlaceholdersNorm-4        36.0 ± 0%      36.0 ± 0%     ~     (all equal)

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @cucaroach and @mgartner)

Copy link
Copy Markdown
Contributor

@cucaroach cucaroach left a comment

Choose a reason for hiding this comment

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

Nice! I figured there had to be a way to just completely avoid all this work.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)

Copy link
Copy Markdown
Contributor

@cucaroach cucaroach left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)

This commit fixes a regression that was due to unnecessary computation
of interesting orderings. We now only compute interesting orderings
when it may be beneficial for planning purposes.

Fixes cockroachdb#72001

Release note (performance improvement): Fixed a performance regression
in planning that could occur for simple queries on schemas with a large
number of indexes.
@rytaft
Copy link
Copy Markdown
Collaborator Author

rytaft commented Oct 29, 2021

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 29, 2021

Build failed:

Copy link
Copy Markdown
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Brilliant.

Copy link
Copy Markdown
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Brilliant.

Definitely a team effort!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 29, 2021

Build succeeded:

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: many columns/index planning benchmarks got a lot more expensive

4 participants