Avoid selecting attributes in the history api when no_attributes is passed#68352
Avoid selecting attributes in the history api when no_attributes is passed#68352bdraco merged 8 commits intohome-assistant:devfrom
no_attributes is passed#68352Conversation
- Most history api requests do not need attributes and throw them away. We can avoid selecting them in the first place if we do not need them
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
no_attributes is passed
|
So these two history apis need a way to not fetch them as well |
|
The |
|
The |
|
The |
|
Dropping the attributes on the frontend in testing was with - Run Time: real 1.891 user 0.041000 sys 0.053000 |
|
Proposed change
We want to get rid of direct database access in integrations, but there currently
is no way to avoid selecting attributes.
Additionally, attribute selection in history database queries make up most of the payload size.
With
minimal_responseswe throw away 85%+ of the payload because most history apirequests do not need attributes and throw them away except for the unit of measurement
We can avoid selecting them in the first place for domains that
do not need them and already have the unit of measurement in memory via
the state machine
Now that attributes are stored in another table we can avoid traversing and
fetching the data from the database when they aren't needed
A new flag
no_attributesis added to the history api which can be appliedwhen calls already have the attributes needed (currently unit of measurement)
Type of change
Additional information
no_attributesflag for history api developers.home-assistant#1242Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: