@@ -150,11 +150,11 @@ SELECT date_trunc('second', time) t, avg(series_0), min(series_1), avg(series_2)
150
150
151
151
--test that when index on time used by constraint, still works correctly
152
152
EXPLAIN (costs off)
153
- SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
154
- FROM hyper_1
155
- WHERE time < to_timestamp(900)
156
- GROUP BY t
157
- ORDER BY t DESC
153
+ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
154
+ FROM hyper_1
155
+ WHERE time < to_timestamp(900)
156
+ GROUP BY t
157
+ ORDER BY t DESC
158
158
LIMIT 2;
159
159
QUERY PLAN
160
160
-----------------------------------------------------------------------------------------------------------
@@ -170,11 +170,11 @@ LIMIT 2;
170
170
Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
171
171
(10 rows)
172
172
173
- SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
174
- FROM hyper_1
175
- WHERE time < to_timestamp(900)
176
- GROUP BY t
177
- ORDER BY t DESC
173
+ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
174
+ FROM hyper_1
175
+ WHERE time < to_timestamp(900)
176
+ GROUP BY t
177
+ ORDER BY t DESC
178
178
LIMIT 2;
179
179
t | avg | min | avg
180
180
--------------------------+-------+-------+------------------
@@ -235,7 +235,7 @@ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
235
235
Wed Dec 31 21:32:00 1969 | 19949.5 | 29920 | 141.242685621416
236
236
(2 rows)
237
237
238
- EXPLAIN (costs off) SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
238
+ EXPLAIN (costs off) SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
239
239
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
240
240
QUERY PLAN
241
241
------------------------------------------------------------------------------------------
@@ -249,15 +249,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
249
249
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
250
250
(8 rows)
251
251
252
- SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
252
+ SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
253
253
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
254
254
t | avg | min | avg
255
255
--------------------------+---------+-------+------------------
256
256
Wed Dec 31 21:33:00 1969 | 19990 | 29980 | 141.385994856058
257
257
Wed Dec 31 21:32:00 1969 | 19949.5 | 29920 | 141.242685621416
258
258
(2 rows)
259
259
260
- EXPLAIN (costs off) SELECT time_bucket('1 minute', time, INTERVAL '30 seconds') t, avg(series_0), min(series_1), avg(series_2)
260
+ EXPLAIN (costs off) SELECT time_bucket('1 minute', time, INTERVAL '30 seconds') t, avg(series_0), min(series_1), avg(series_2)
261
261
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
262
262
QUERY PLAN
263
263
-------------------------------------------------------------------------------------------------------------------------------------------
@@ -271,15 +271,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
271
271
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
272
272
(8 rows)
273
273
274
- SELECT time_bucket('1 minute', time, INTERVAL '30 seconds') t, avg(series_0), min(series_1), avg(series_2)
274
+ SELECT time_bucket('1 minute', time, INTERVAL '30 seconds') t, trunc( avg(series_0)::numeric, 8) as avg_trunc1, min(series_1), trunc( avg(series_2)::numeric, 8) as avg_trunc2
275
275
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
276
- t | avg | min | avg
277
- --------------------------+---------+ -------+------------------
278
- Wed Dec 31 21:32:30 1969 | 19975 | 29950 | 141.332930657636
279
- Wed Dec 31 21:31:30 1969 | 19919.5 | 29890 | 141.136445455771
276
+ t | avg_trunc1 | min | avg_trunc2
277
+ --------------------------+----------------+-------+ --------------
278
+ Wed Dec 31 21:32:30 1969 | 19975.00000000 | 29950 | 141.33293065
279
+ Wed Dec 31 21:31:30 1969 | 19919.50000000 | 29890 | 141.13644545
280
280
(2 rows)
281
281
282
- EXPLAIN (costs off) SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') t, avg(series_0), min(series_1), avg(series_2)
282
+ EXPLAIN (costs off) SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') t, avg(series_0), min(series_1), avg(series_2)
283
283
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
284
284
QUERY PLAN
285
285
-----------------------------------------------------------------------------------------------------------------
@@ -293,15 +293,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
293
293
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
294
294
(8 rows)
295
295
296
- SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') t, avg(series_0), min(series_1), avg(series_2)
296
+ SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') t, trunc( avg(series_0)::numeric, 8) as avg_trunc1, min(series_1), trunc( avg(series_2)::numeric, 8) as avg_trunc2
297
297
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
298
- t | avg | min | avg
299
- --------------------------+---------+ -------+------------------
300
- Wed Dec 31 21:32:00 1969 | 19975 | 29950 | 141.332930657636
301
- Wed Dec 31 21:31:00 1969 | 19919.5 | 29890 | 141.136445455771
298
+ t | avg_trunc1 | min | avg_trunc2
299
+ --------------------------+----------------+-------+ --------------
300
+ Wed Dec 31 21:32:00 1969 | 19975.00000000 | 29950 | 141.33293065
301
+ Wed Dec 31 21:31:00 1969 | 19919.50000000 | 29890 | 141.13644545
302
302
(2 rows)
303
303
304
- EXPLAIN (costs off) SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') + INTERVAL '30 seconds' t, avg(series_0), min(series_1), avg(series_2)
304
+ EXPLAIN (costs off) SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') + INTERVAL '30 seconds' t, avg(series_0), min(series_1), avg(series_2)
305
305
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
306
306
QUERY PLAN
307
307
-------------------------------------------------------------------------------------------------------------------------------------------
@@ -315,15 +315,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
315
315
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
316
316
(8 rows)
317
317
318
- SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') + INTERVAL '30 seconds' t, avg(series_0), min(series_1), avg(series_2)
318
+ SELECT time_bucket('1 minute', time - INTERVAL '30 seconds') + INTERVAL '30 seconds' t, trunc( avg(series_0)::numeric, 8) as avg_trunc1, min(series_1), trunc( avg(series_2)::numeric, 8) as avg_trunc2
319
319
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
320
- t | avg | min | avg
321
- --------------------------+---------+ -------+------------------
322
- Wed Dec 31 21:32:30 1969 | 19975 | 29950 | 141.332930657636
323
- Wed Dec 31 21:31:30 1969 | 19919.5 | 29890 | 141.136445455771
320
+ t | avg_trunc1 | min | avg_trunc2
321
+ --------------------------+----------------+-------+ --------------
322
+ Wed Dec 31 21:32:30 1969 | 19975.00000000 | 29950 | 141.33293065
323
+ Wed Dec 31 21:31:30 1969 | 19919.50000000 | 29890 | 141.13644545
324
324
(2 rows)
325
325
326
- EXPLAIN (costs off) SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
326
+ EXPLAIN (costs off) SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
327
327
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
328
328
QUERY PLAN
329
329
---------------------------------------------------------------------------------------------
@@ -337,15 +337,15 @@ FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
337
337
-> Index Scan using _hyper_2_2_chunk_time_plain_tz on _hyper_2_2_chunk
338
338
(8 rows)
339
339
340
- SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
340
+ SELECT time_bucket('1 minute', time) t, avg(series_0), min(series_1), avg(series_2)
341
341
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
342
342
t | avg | min | avg
343
343
------------------------------+---------+-------+------------------
344
344
Wed Dec 31 21:33:00 1969 PST | 19990 | 29980 | 141.385994856058
345
345
Wed Dec 31 21:32:00 1969 PST | 19949.5 | 29920 | 141.242685621416
346
346
(2 rows)
347
347
348
- EXPLAIN (costs off) SELECT time_bucket('1 minute', time::timestamp) t, avg(series_0), min(series_1), avg(series_2)
348
+ EXPLAIN (costs off) SELECT time_bucket('1 minute', time::timestamp) t, avg(series_0), min(series_1), avg(series_2)
349
349
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
350
350
QUERY PLAN
351
351
-------------------------------------------------------------------------------------------------------------------------
@@ -359,15 +359,15 @@ FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
359
359
-> Index Scan using _hyper_2_2_chunk_time_plain_tz on _hyper_2_2_chunk
360
360
(8 rows)
361
361
362
- SELECT time_bucket('1 minute', time::timestamp) t, avg(series_0), min(series_1), avg(series_2)
362
+ SELECT time_bucket('1 minute', time::timestamp) t, avg(series_0), min(series_1), avg(series_2)
363
363
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
364
364
t | avg | min | avg
365
365
--------------------------+---------+-------+------------------
366
366
Wed Dec 31 21:33:00 1969 | 19990 | 29980 | 141.385994856058
367
367
Wed Dec 31 21:32:00 1969 | 19949.5 | 29920 | 141.242685621416
368
368
(2 rows)
369
369
370
- EXPLAIN (costs off) SELECT time_bucket(10, time) t, avg(series_0), min(series_1), avg(series_2)
370
+ EXPLAIN (costs off) SELECT time_bucket(10, time) t, avg(series_0), min(series_1), avg(series_2)
371
371
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
372
372
QUERY PLAN
373
373
----------------------------------------------------------------------------------------------
@@ -383,15 +383,15 @@ FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
383
383
-> Index Scan using _hyper_3_5_chunk_time_plain_int on _hyper_3_5_chunk
384
384
(10 rows)
385
385
386
- SELECT time_bucket(10, time) t, avg(series_0), min(series_1), avg(series_2)
386
+ SELECT time_bucket(10, time) t, avg(series_0), min(series_1), avg(series_2)
387
387
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
388
388
t | avg | min | avg
389
389
-------+---------+-------+------------------
390
390
20000 | 20000 | 30000 | 141.42135623731
391
391
19990 | 19994.5 | 29990 | 141.401909099017
392
392
(2 rows)
393
393
394
- EXPLAIN (costs off) SELECT time_bucket(10, time, 2) t, avg(series_0), min(series_1), avg(series_2)
394
+ EXPLAIN (costs off) SELECT time_bucket(10, time, 2) t, avg(series_0), min(series_1), avg(series_2)
395
395
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
396
396
QUERY PLAN
397
397
----------------------------------------------------------------------------------------------
@@ -407,7 +407,7 @@ FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
407
407
-> Index Scan using _hyper_3_5_chunk_time_plain_int on _hyper_3_5_chunk
408
408
(10 rows)
409
409
410
- SELECT time_bucket(10, time) t, avg(series_0), min(series_1), avg(series_2)
410
+ SELECT time_bucket(10, time) t, avg(series_0), min(series_1), avg(series_2)
411
411
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
412
412
t | avg | min | avg
413
413
-------+---------+-------+------------------
@@ -417,11 +417,11 @@ FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
417
417
418
418
--plain tables shouldnt be optimized by default
419
419
EXPLAIN (costs off)
420
- SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
421
- FROM plain_table
422
- WHERE time < to_timestamp(900)
423
- GROUP BY t
424
- ORDER BY t DESC
420
+ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
421
+ FROM plain_table
422
+ WHERE time < to_timestamp(900)
423
+ GROUP BY t
424
+ ORDER BY t DESC
425
425
LIMIT 2;
426
426
QUERY PLAN
427
427
-----------------------------------------------------------------------------------------------------------
@@ -436,11 +436,11 @@ LIMIT 2;
436
436
Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
437
437
(9 rows)
438
438
439
- SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
440
- FROM plain_table
441
- WHERE time < to_timestamp(900)
442
- GROUP BY t
443
- ORDER BY t DESC
439
+ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
440
+ FROM plain_table
441
+ WHERE time < to_timestamp(900)
442
+ GROUP BY t
443
+ ORDER BY t DESC
444
444
LIMIT 2;
445
445
t | avg | min | avg
446
446
------------------------------+-------+-------+------------------
@@ -452,11 +452,11 @@ LIMIT 2;
452
452
BEGIN;
453
453
SET LOCAL timescaledb.optimize_non_hypertables = 'on';
454
454
EXPLAIN (costs off)
455
- SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
456
- FROM plain_table
457
- WHERE time < to_timestamp(900)
458
- GROUP BY t
459
- ORDER BY t DESC
455
+ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
456
+ FROM plain_table
457
+ WHERE time < to_timestamp(900)
458
+ GROUP BY t
459
+ ORDER BY t DESC
460
460
LIMIT 2;
461
461
QUERY PLAN
462
462
-----------------------------------------------------------------------------------------------
@@ -467,11 +467,11 @@ BEGIN;
467
467
Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
468
468
(5 rows)
469
469
470
- SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
471
- FROM plain_table
472
- WHERE time < to_timestamp(900)
473
- GROUP BY t
474
- ORDER BY t DESC
470
+ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
471
+ FROM plain_table
472
+ WHERE time < to_timestamp(900)
473
+ GROUP BY t
474
+ ORDER BY t DESC
475
475
LIMIT 2;
476
476
t | avg | min | avg
477
477
------------------------------+-------+-------+------------------
0 commit comments