hass-core/homeassistant
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 76a6371705 - 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
..
components History performance improvements for single-entity requests (#8632) 2017-07-26 11:22:01 -04:00
helpers Tweak conversation/intent/shopping list (#8636) 2017-07-25 00:42:59 -07:00
scripts Add support for using credstash as a secret store (#8494) 2017-07-24 08:59:10 -07:00
util Added support for default value when environment variable is missing (#8484) 2017-07-24 09:00:01 -07:00
__init__.py Fix PEP257 issues 2016-03-08 00:06:04 +01:00
__main__.py Fix some issues for PyLint 1.7.2 (#8356) 2017-07-05 20:02:16 -07:00
bootstrap.py Update docstrings (#8536) 2017-07-18 16:23:57 +02:00
config.py Update persistent deps dir version in config.py (#8479) 2017-07-19 22:59:21 -07:00
const.py Version bump to 0.50.0dev0 2017-07-15 21:07:15 -07:00
core.py Expose all components on hass [Concept] (#8490) 2017-07-16 09:23:06 -07:00
exceptions.py EntityComponent to retry platforms that are not ready yet (#8209) 2017-06-26 09:41:48 -07:00
loader.py Expose all components on hass [Concept] (#8490) 2017-07-16 09:23:06 -07:00
monkey_patch.py Make monkey patch work in Python 3.6 (#7848) 2017-06-01 23:23:39 -07:00
package_constraints.txt Make deps directory persistent over upgrades (#7801) 2017-07-13 19:26:21 -07:00
remote.py Fix pylint 1.7.2 no-else-return issues (#8361) 2017-07-05 23:30:01 -07:00
setup.py Fix check for running inside venv (#8481) 2017-07-15 07:25:02 -07:00