Skip to content

opt: add SerializingProject exec primitive#52386

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
RaduBerinde:serializing-project
Aug 5, 2020
Merged

opt: add SerializingProject exec primitive#52386
craig[bot] merged 1 commit intocockroachdb:masterfrom
RaduBerinde:serializing-project

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde commented Aug 5, 2020

The top-level projection of a query has a special property - it can project away
columns that we want an ordering on (e.g. SELECT a FROM t ORDER BY b).

The distsql physical planner was designed to tolerate such cases, as they were
much more common with the heuristic planner. But the new distsql exec factory
does not; it currently relies on a hack: it detects this case by checking if the
required output ordering is nil. This is fragile and doesn't work in all
cases.

This change adds a SerializingProject primitive which is like a SimpleProject
but it forces serialization of all parallel streams into one. The new primitive
is used to enforce the final query presentation. We only need to pass column
names for the presentation, so we remove RenameColumns and remove the column
names argument from SimpleProject (simplifying some execbuilder code).

We also fix a bug in ConstructSimpleProject where we weren't taking the
PlanToStreamColMap into account when building the projection.

Release note: None

@RaduBerinde RaduBerinde requested a review from yuzefovich August 5, 2020 03:36
@RaduBerinde RaduBerinde requested a review from a team as a code owner August 5, 2020 03:36
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@RaduBerinde RaduBerinde force-pushed the serializing-project branch from 8738979 to af11fa9 Compare August 5, 2020 03:36
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks for working on this!

Reviewed 7 of 7 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

The top-level projection of a query has a special property - it can project away
columns that we want an ordering on (e.g. `SELECT a FROM t ORDER BY b`).

The distsql physical planner was designed to tolerate such cases, as they were
much more common with the heuristic planner. But the new distsql exec factory
does not; it currently relies on a hack: it detects this case by checking if the
required output ordering is `nil`. This is fragile and doesn't work in all
cases.

This change adds a `SerializingProject` primitive which is like a SimpleProject
but it forces serialization of all parallel streams into one. The new primitive
is used to enforce the final query presentation. We only need to pass column
names for the presentation, so we remove `RenameColumns` and remove the column
names argument from `SimpleProject` (simplifying some execbuilder code).

We also fix a bug in `ConstructSimpleProject` where we weren't taking the
`PlanToStreamColMap` into account when building the projection.

Release note: None
@RaduBerinde RaduBerinde force-pushed the serializing-project branch from af11fa9 to 509b76d Compare August 5, 2020 16:13
@RaduBerinde
Copy link
Copy Markdown
Member Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 5, 2020

Build succeeded:

@craig craig bot merged commit 67a92cd into cockroachdb:master Aug 5, 2020
@RaduBerinde RaduBerinde deleted the serializing-project branch August 12, 2020 18:08
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