Optimize logbook SQL query again#12881
Merged
balloob merged 1 commit intohome-assistant:devfrom Mar 3, 2018
Merged
Conversation
balloob
approved these changes
Mar 3, 2018
Merged
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This brings back #12608. It was reverted in #12762 because of a report that it slowed the logbook down to be unusable. I have worked with @jjlawren to analyze this issue and it is fully fixed by the index that #12825 proposes.
Also note that reverting the optimization made the logbook similarly unusable with other workloads.
I believe the index and this optimization in tandem will avoid the pathological slowdown in both scenarios (I'm afraid to say "all scenarios" because databases are strange and we support so many of them).
The last line of the patch compares a field with NULL to include rows with no match in the outer join. I have changed this field from
last_updatedtostate_idto make it more clear that this is about missing rows and not the value of some particular field.Checklist:
If the code does not interact with devices:
toxrun successfully.