mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-19 12:13:24 +08:00
Common time-series rollups are of the form SELECT date_trunc(const, time) as t, aggregates... GROUP BY t ORDER BY t DESC LIMIT const2. Previously, Postgres would not optimize such queries because it could not match date_trunc(const, time) to any indexes on time, since it has no way to know that a sort on time is always a valid sort on date_trunc(const, time). This commit implements this optimization for date_trunc but it could apply to a wider range of functions, to be implemented later.
3 lines
156 B
SQL
3 lines
156 B
SQL
--make sure diff only has explain output not result output
|
|
\! diff ../results/sql_query_results_optimized.out ../results/sql_query_results_unoptimized.out
|