hass-core/homeassistant/components/recorder
Alex Hermann bdef0ba6e5
Significantly improve performance for some cases of the history start time state query (#99450)
* recorder: Apply filter in the outer query too

Function _get_start_time_state_for_entities_stmt() produced a query which
is dead-slow in my installation. On analysis, the outer query produced
millions of rows which had to be joined to the subquery. The subquery has
a filter which would eliminate almost all of the outer rows.

To speed up the query, apply the same filter to the outer query, so way
less rows have to be joined.

This reduced the query time on my system from more than half an hour to
mere milliseconds.

* lint

* merge filter

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-11-28 16:23:49 -06:00
..
auto_repairs Switch formatting from black to ruff-format (#102893) 2023-11-27 14:38:59 +01:00
history Significantly improve performance for some cases of the history start time state query (#99450) 2023-11-28 16:23:49 -06:00
models Increase max bind vars based on database version (#101464) 2023-10-06 07:59:38 +02:00
system_health
table_managers Update mypy to 1.7.0 (#103800) 2023-11-11 23:31:04 +01:00
__init__.py Move event permissions out of the websocket api into auth (#101975) 2023-10-15 23:14:19 +02:00
backup.py
const.py Move event permissions out of the websocket api into auth (#101975) 2023-10-15 23:14:19 +02:00
core.py Increase max bind vars based on database version (#101464) 2023-10-06 07:59:38 +02:00
db_schema.py Switch formatting from black to ruff-format (#102893) 2023-11-27 14:38:59 +01:00
entity_registry.py
executor.py Remove unnnecessary pylint configs from components [m-r]* (#98924) 2023-08-24 00:56:50 +02:00
filters.py Switch formatting from black to ruff-format (#102893) 2023-11-27 14:38:59 +01:00
manifest.json Bump SQLAlchemy to 2.0.23 (#103313) 2023-11-03 11:10:08 -05:00
migration.py Switch formatting from black to ruff-format (#102893) 2023-11-27 14:38:59 +01:00
pool.py
purge.py Chunk purging attributes and data ids for old SQLite versions (#104296) 2023-11-24 11:46:02 +01:00
queries.py Recover from previously failed statistics migrations (#101781) 2023-10-22 23:34:43 -04:00
repack.py
services.py
services.yaml
statistics.py Update mypy to 1.7.0 (#103800) 2023-11-11 23:31:04 +01:00
strings.json
tasks.py
util.py Chunk purging attributes and data ids for old SQLite versions (#104296) 2023-11-24 11:46:02 +01:00
websocket_api.py