Skip to content
Snippets Groups Projects
Unverified Commit b64ae55c authored by J. Nick Koston's avatar J. Nick Koston Committed by GitHub
Browse files

Prebake common history queries (#37496)


* Prebake common history queries

The python overhead of to construct
the queries exceeded the database overhead.  We now
prebake the queries that get frequently polled.

This reduces the time it takes to update history_stats
sensors and can make quite a difference if there
are a lot of them.

When using the mini-graph-card card, all the entities
on the card being graphed are queried every few seconds
for new states. Previously this would tie up the database if there
are lot of these graphs in the UI.

* Update homeassistant/components/history/__init__.py

Co-authored-by: default avatarPaulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/history/__init__.py

Co-authored-by: default avatarPaulus Schoutsen <paulus@home-assistant.io>

* cache entity_filter in the lambda

* switch to yield

* Revert "switch to yield"

This reverts commit f8386f494002178729b67b54dd299affd406f2f2.

* get_states always returns a list

* query wasnt actually reusable so revert part of the breakout

Co-authored-by: default avatarPaulus Schoutsen <paulus@home-assistant.io>
parent 8bc775da
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment