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.
Browse files
Browse the repository at this point in the history
28774: opt: fix building of aggregates with outer columns r=rytaft a=rytaft This commit fixes a bug in which aggregates containing outer columns were associated with the wrong scope. For example, consider this query: ``` SELECT (SELECT max(a.x) FROM b) FROM a; ``` Previously, the inner (subquery) scope was selected as the grouping scope for `max(a.x)`. However, this was incorrect. The outer scope should have been selected instead. In order to fix this issue, this commit makes significant changes to the way queries are built by the `optbuilder`. It is difficult to determine whether a particular select clause needs aggregation without first building the arguments to the aggregates to see whether there are outer columns. Therefore, this commit makes the following change: before any expressions in the `SELECT` list are built, all aggregates in the `SELECT`, `DISTINCT ON`, `ORDER BY`, and `HAVING` clauses are replaced with an `aggregateInfo`. The `aggregateInfo` contains the function definition, fully built arguments, and output column of the aggregate. In order to avoid traversing the expression tree multiple times, the entire semantic analysis and type checking phase is completed before building any non-aggregates for these clauses. This commit avoids allocating slices for analyzed expressions by instead creating them as columns directly in the scope which will use them. It later makes another pass through the columns to build them. This and various other performance improvements make the fix for correlated aggregates perform at parity with the master branch. Master branch: ``` name time/op Phases/kv-read/OptBuild 18.8µs ± 4% Phases/planning1/OptBuild 8.06µs ± 3% Phases/planning2/OptBuild 20.3µs ± 5% Phases/planning3/OptBuild 22.0µs ± 3% Phases/planning4/OptBuild 24.1µs ± 4% Phases/planning5/OptBuild 22.2µs ± 8% Phases/planning6/OptBuild 36.8µs ± 2% ``` Correlated aggs: ``` name time/op Phases/kv-read/OptBuild 18.4µs ± 3% Phases/planning1/OptBuild 7.92µs ± 1% Phases/planning2/OptBuild 20.6µs ± 4% Phases/planning3/OptBuild 22.2µs ± 4% Phases/planning4/OptBuild 24.1µs ± 3% Phases/planning5/OptBuild 21.4µs ± 1% Phases/planning6/OptBuild 36.3µs ± 2% ``` Fixes cockroachdb#12703 Release note: None 29213: cli: Fix support for deprecated --http-host flag r=a-robinson a=a-robinson It looks like we accidentally stopped registering the --http-host flag in the cli package's init function recently, which completely removed support for --http-host rather than the intended effect of deprecating (but continuing to allow) it. Also make the handling of deprecated/alias flags more consistent with each other while I'm here. Release note (bug fix): Fix support for --http-host flag that was broken in previous 2.1 beta releases. Co-authored-by: Rebecca Taft <[email protected]> Co-authored-by: Alex Robinson <[email protected]>
- Loading branch information
Showing
54 changed files
with
2,150 additions
and
1,359 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
Oops, something went wrong.