Skip to content

Optimize logbook SQL query again#12881

Merged
balloob merged 1 commit intohome-assistant:devfrom
amelchio:logbook-join-states-again
Mar 3, 2018
Merged

Optimize logbook SQL query again#12881
balloob merged 1 commit intohome-assistant:devfrom
amelchio:logbook-join-states-again

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

@amelchio amelchio commented Mar 3, 2018

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_updated to state_id to make it more clear that this is about missing rows and not the value of some particular field.

Checklist:

  • The code change is tested and works locally.

If the code does not interact with devices:

  • Local tests with tox run successfully.
  • Tests have been added to verify that the new code works.

@balloob balloob merged commit 54f8f12 into home-assistant:dev Mar 3, 2018
@amelchio amelchio mentioned this pull request Mar 4, 2018
3 tasks
@balloob balloob mentioned this pull request Mar 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants