mirror of
https://github.com/home-assistant/core.git
synced 2025-08-06 22:25:13 +02:00
Add DEBUG-level log for db row to native object conversion
This is now the bottleneck (by a large margin) for big history queries, so I'm leaving this log feature in to help diagnose users with a slow history page
This commit is contained in:
@@ -58,10 +58,19 @@ def execute(qry):
|
|||||||
|
|
||||||
for tryno in range(0, RETRIES):
|
for tryno in range(0, RETRIES):
|
||||||
try:
|
try:
|
||||||
return [
|
timer_start = time.perf_counter()
|
||||||
|
result = [
|
||||||
row for row in
|
row for row in
|
||||||
(row.to_native() for row in qry)
|
(row.to_native() for row in qry)
|
||||||
if row is not None]
|
if row is not None]
|
||||||
|
|
||||||
|
if _LOGGER.isEnabledFor(logging.DEBUG):
|
||||||
|
elapsed = time.perf_counter() - timer_start
|
||||||
|
_LOGGER.debug('converting %d rows to native objects took %fs',
|
||||||
|
len(result),
|
||||||
|
elapsed)
|
||||||
|
|
||||||
|
return result
|
||||||
except SQLAlchemyError as err:
|
except SQLAlchemyError as err:
|
||||||
_LOGGER.error("Error executing query: %s", err)
|
_LOGGER.error("Error executing query: %s", err)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user