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

Remove RunId from visibility query sort for ES 7 #3140

Merged
merged 6 commits into from
Jul 27, 2022

Conversation

meiliang86
Copy link
Contributor

@meiliang86 meiliang86 commented Jul 25, 2022

What changed?
Remove RunId from visibility query sort for ES v7.

Why?
Improve query performance

How did you test it?
Manually sending queries to ES

Potential risks
Duplicate or missing entries when doing pagination.
Although this is unlikely because both closed time and start time has nano seconds precision in ES v7.
For ES v6 this is not changed because date has only milliseconds precision and collisions are more likely.

Is hotfix candidate?
Could be.

@@ -65,7 +65,6 @@ const (
var defaultSorter = []elastic.Sorter{
elastic.NewFieldSort(searchattribute.CloseTime).Desc().Missing("_first"),
elastic.NewFieldSort(searchattribute.StartTime).Desc().Missing("_first"),
elastic.NewFieldSort(searchattribute.RunID).Desc().Missing("_first"),
Copy link
Member

Choose a reason for hiding this comment

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

You need to change setDefaultFieldSort too.

Copy link
Member

Choose a reason for hiding this comment

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

I just read PR description. I believe it should be removed from setDefaultFieldSort in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried and I feel we should not do it. So I reverted the change. There are two reasons:
(1) We are disabling user specified orderby by default. This is not an issue if that's not turned on.
(2) If user intentionally turn it on, then removing the RunId as tie-breaker can cause a behavior change, if user does not specify all tie-breakers in order by (very likely the case, e.g. if they order by some custom search attributes with low cardinality).

Copy link
Member

Choose a reason for hiding this comment

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

Default value for disable ORDER BY is false. But I agree that if custom order is specified then query is already slow. Adding RunId won't hurt much.

@alexshtin alexshtin changed the title Remove runID from visibility query sort Remove RunId from visibility query sort Jul 26, 2022
@meiliang86 meiliang86 changed the title Remove RunId from visibility query sort Remove RunId from visibility query sort for ES 7 Jul 27, 2022
@meiliang86 meiliang86 enabled auto-merge (squash) July 27, 2022 18:50
@meiliang86 meiliang86 merged commit 77aaf84 into temporalio:master Jul 27, 2022
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.

None yet

3 participants