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 keypull/89941/head^2
parent
f27d73fc34
commit
817ba97227
|
@ -1969,8 +1969,8 @@ def _latest_short_term_statistics_stmt(
|
||||||
metadata_ids: list[int],
|
metadata_ids: list[int],
|
||||||
) -> StatementLambdaElement:
|
) -> StatementLambdaElement:
|
||||||
"""Create the statement for finding the latest short term stat rows."""
|
"""Create the statement for finding the latest short term stat rows."""
|
||||||
stmt = lambda_stmt(lambda: select(*QUERY_STATISTICS_SHORT_TERM))
|
return lambda_stmt(
|
||||||
stmt += lambda s: s.join(
|
lambda: select(*QUERY_STATISTICS_SHORT_TERM).join(
|
||||||
(
|
(
|
||||||
most_recent_statistic_row := (
|
most_recent_statistic_row := (
|
||||||
select(
|
select(
|
||||||
|
@ -1986,7 +1986,7 @@ def _latest_short_term_statistics_stmt(
|
||||||
(StatisticsShortTerm.metadata_id == most_recent_statistic_row.c.metadata_id)
|
(StatisticsShortTerm.metadata_id == most_recent_statistic_row.c.metadata_id)
|
||||||
& (StatisticsShortTerm.start_ts == most_recent_statistic_row.c.start_max),
|
& (StatisticsShortTerm.start_ts == most_recent_statistic_row.c.start_max),
|
||||||
)
|
)
|
||||||
return stmt
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_latest_short_term_statistics(
|
def get_latest_short_term_statistics(
|
||||||
|
|
Loading…
Reference in New Issue