mirror of
https://github.com/home-assistant/core.git
synced 2025-08-17 19:41:45 +02:00
restore lost performance
This commit is contained in:
@@ -513,10 +513,9 @@ def _get_states_for_entities_stmt(
|
|||||||
no_attributes: bool,
|
no_attributes: bool,
|
||||||
) -> Select:
|
) -> Select:
|
||||||
"""Baked query to get states for specific entities."""
|
"""Baked query to get states for specific entities."""
|
||||||
stmt = _stmt_and_join_attributes(no_attributes, True)
|
|
||||||
# We got an include-list of entities, accelerate the query by filtering already
|
# We got an include-list of entities, accelerate the query by filtering already
|
||||||
# in the inner query.
|
# in the inner query.
|
||||||
stmt = stmt.join(
|
stmt = _stmt_and_join_attributes(no_attributes, True).join(
|
||||||
(
|
(
|
||||||
most_recent_states_for_entities_by_date := (
|
most_recent_states_for_entities_by_date := (
|
||||||
select(
|
select(
|
||||||
@@ -541,11 +540,11 @@ def _get_states_for_entities_stmt(
|
|||||||
== most_recent_states_for_entities_by_date.c.max_last_updated,
|
== most_recent_states_for_entities_by_date.c.max_last_updated,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if not no_attributes:
|
if no_attributes:
|
||||||
stmt = stmt.outerjoin(
|
return stmt
|
||||||
StateAttributes, (States.attributes_id == StateAttributes.attributes_id)
|
return stmt.outerjoin(
|
||||||
)
|
StateAttributes, (States.attributes_id == StateAttributes.attributes_id)
|
||||||
return stmt
|
)
|
||||||
|
|
||||||
|
|
||||||
def _get_run_start_ts_from_run_for_utc_point_in_time(
|
def _get_run_start_ts_from_run_for_utc_point_in_time(
|
||||||
|
Reference in New Issue
Block a user