Remove unneeded lambda_stmt in place add in statistics (#89943)

We can generate this entire query in a single lambda_stmt
so there is no need to add two which increases the size
of the cache key
pull/89941/head^2
J. Nick Koston 2023-03-19 16:05:39 -10:00 committed by GitHub
parent f27d73fc34
commit 817ba97227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 17 deletions

View File

@ -1969,8 +1969,8 @@ def _latest_short_term_statistics_stmt(
metadata_ids: list[int],
) -> StatementLambdaElement:
"""Create the statement for finding the latest short term stat rows."""
stmt = lambda_stmt(lambda: select(*QUERY_STATISTICS_SHORT_TERM))
stmt += lambda s: s.join(
return lambda_stmt(
lambda: select(*QUERY_STATISTICS_SHORT_TERM).join(
(
most_recent_statistic_row := (
select(
@ -1986,7 +1986,7 @@ def _latest_short_term_statistics_stmt(
(StatisticsShortTerm.metadata_id == most_recent_statistic_row.c.metadata_id)
& (StatisticsShortTerm.start_ts == most_recent_statistic_row.c.start_max),
)
return stmt
)
def get_latest_short_term_statistics(