Files
core/homeassistant/components
Greg Laabs 438edc5ca1 History performance improvements for single-entity requests (#8632)
* Bugfix: remove superfluous domain filter

This filter is already applied later in the function by the `filters` object, where it is conditionally applied when appropriate. This fixes the problem where we get a domain filter even when searching for a single entity_id, which needlessly harms the query's performance.

* Performance: build different query when only getting single entity

When querying the history of a single entity, we can use an entirely different method for the "synthetic zero data point" by simply sorting by date and doing a LIMIT 1. This performs thousands of times better than the multi-entity query when the current recorder_run has been going for a while.

* Add entity_id filter to single-entity request

The entity_id filter was handled inside the `filters.apply` logic which is used in most cases, BUT didn't work when no `filters` was passed in to the method. Now it'll work even if no `filters` object is passed in.

* Fix linting errors in history.py

* Undo removal of domain filter

Putting back the domain filter that was removed in 76a6371705dcd57483e55dcc03435ae867c184d2 - there are use-cases where get_states is called without a filter object, so we need the domain filter to work in those cases as well.

* Fix truncated comment
2017-07-26 11:22:01 -04:00
..
2017-07-26 14:03:29 +02:00
2017-07-23 23:48:20 -07:00
2017-07-26 14:03:29 +02:00
2017-07-26 14:03:29 +02:00
2017-07-25 00:29:05 -07:00
2017-06-08 15:53:12 +02:00
2017-07-26 14:03:29 +02:00
2017-07-16 10:14:46 -07:00
2017-07-16 10:14:46 -07:00
2017-07-16 10:14:46 -07:00
2017-07-26 14:03:29 +02:00
2017-07-06 22:20:49 -07:00
2017-07-21 21:22:43 -07:00
2017-07-21 21:38:53 -07:00
2017-07-23 23:46:23 -07:00
2017-07-21 21:38:53 -07:00
2017-07-16 21:39:38 +02:00
2017-07-16 21:39:38 +02:00
2017-04-29 22:04:49 -07:00
2017-05-12 20:30:07 -07:00
2017-04-29 22:04:49 -07:00
2016-07-16 23:45:38 -07:00
2017-06-29 11:44:35 +02:00
2017-05-06 00:34:40 +02:00
2017-07-18 15:11:17 -07:00
2017-05-11 22:48:03 +02:00
2017-07-07 16:59:41 -07:00
2017-05-04 07:48:43 +02:00
2017-05-02 22:47:20 +02:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-07-16 10:14:46 -07:00
2017-05-02 22:47:20 +02:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-07-21 21:38:53 -07:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-05-04 13:14:14 -07:00
2017-06-05 08:39:31 -07:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-06-11 22:19:10 -07:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2016-08-11 11:14:24 +02:00
2017-04-29 22:04:49 -07:00
2017-05-02 22:47:20 +02:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-07-16 21:39:38 +02:00
2017-04-29 22:04:49 -07:00
2017-07-16 10:14:46 -07:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-06-21 00:32:04 +02:00
2017-04-29 22:04:49 -07:00
2017-07-21 21:38:53 -07:00
2017-04-29 22:04:49 -07:00
2017-07-02 12:54:59 -07:00
2017-04-29 22:04:49 -07:00
2017-03-26 15:50:40 +02:00
2017-07-16 21:39:38 +02:00
2017-07-26 14:03:29 +02:00
2017-07-10 12:11:16 +02:00
2017-07-04 06:26:55 +02:00
2017-04-29 22:04:49 -07:00
2017-04-29 22:04:49 -07:00
2017-06-15 21:25:19 +02:00
2017-04-29 22:04:49 -07:00
2017-07-16 10:14:46 -07:00