Skip to content
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

rowexec: allow ordered joinReader to stream matches to the first row #85731

Merged
merged 1 commit into from
Aug 9, 2022

Conversation

DrewKimball
Copy link
Collaborator

Currently the joinReaderOrderingStrategy implementation buffers all looked up
rows before matching them with input rows and emitting them. This is necessary
because the looked up rows may not be received in input order (which must be
maintained). However, rows that match the first input row can be emitted
immediately. In the case when there are many rows that match the first input
row, this can decrease overhead of the buffer. Additionally, this change can
allow a limit to be satisfied earlier, which can significantly decrease
latency. This is especially advantageous in the case when there is only one
input row, since all lookups can then be rendered and returned in streaming
fashion.

Release note (performance improvement): The execution engine can now
short-circuit execution of lookup joins in more cases, which can decrease
latency for queries with limits.

@DrewKimball DrewKimball requested a review from a team as a code owner August 8, 2022 11:26
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
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.

Nice idea! :lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)


pkg/sql/rowexec/joinreader_strategies.go line 516 at r1 (raw file):

		//  on. This could significantly decrease the overhead of buffering looked
		//  up rows.
		unbufferedRow rowenc.EncDatumRow

nit: "unbuffered" reads unusual to me, maybe "notBuffered" would be better?


pkg/sql/rowexec/joinreader_strategies.go line 654 at r1 (raw file):

		if !s.isPartialJoin {
			if inputRowIdx == 0 {
				// Don't add to inputRowIdxToLookedUpRowIndices in order to avoid

nit: it'd be good to update the comment on inputRowIdxToLookedUpRowIndices accordingly.

Copy link
Collaborator Author

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/rowexec/joinreader_strategies.go line 516 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: "unbuffered" reads unusual to me, maybe "notBuffered" would be better?

Done.


pkg/sql/rowexec/joinreader_strategies.go line 654 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: it'd be good to update the comment on inputRowIdxToLookedUpRowIndices accordingly.

Done.

Currently the `joinReaderOrderingStrategy` implementation buffers all looked up
rows before matching them with input rows and emitting them. This is necessary
because the looked up rows may not be received in input order (which must be
maintained). However, rows that match the first input row can be emitted
immediately. In the case when there are many rows that match the first input
row, this can decrease overhead of the buffer. Additionally, this change can
allow a limit to be satisfied earlier, which can significantly decrease
latency. This is especially advantageous in the case when there is only one
input row, since all lookups can then be rendered and returned in streaming
fashion.

Release note (performance improvement): The execution engine can now
short-circuit execution of lookup joins in more cases, which can decrease
latency for queries with limits.
Copy link
Collaborator Author

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

TFTR!

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

@DrewKimball
Copy link
Collaborator Author

bors r+

@DrewKimball
Copy link
Collaborator Author

Test failure looks like an unrelated flake.

@craig
Copy link
Contributor

craig bot commented Aug 9, 2022

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.

3 participants