Skip to content

Commit 00a096f

Browse files
committed
Modify tests to make more platform agnostic
When testing on Windows these tests were returning differences because of floating point (sql_query_results_*) differences and because the cost was trivially higher (insert_single). Here we remove the costs since it was not relevant to the regressions we want to detect. Further we truncate the floating point averages to 8 decimal places; enough to see significant differences.
1 parent 0e76b5f commit 00a096f

File tree

5 files changed

+192
-192
lines changed

5 files changed

+192
-192
lines changed

test/expected/insert_single.out

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -307,42 +307,42 @@ SELECT * FROM "3dim";
307307
(3 rows)
308308

309309
-- test that explain works
310-
EXPLAIN
310+
EXPLAIN (COSTS FALSE)
311311
INSERT INTO "3dim" VALUES('2017-01-21T09:00:01', 32.9, 'green', 'nyc'),
312312
('2017-01-21T09:00:47', 27.3, 'purple', 'la') RETURNING *;
313-
QUERY PLAN
314-
--------------------------------------------------------------------------------
315-
Custom Scan (HypertableInsert) (cost=0.00..0.03 rows=2 width=80)
316-
-> Insert on "3dim" (cost=0.00..0.03 rows=2 width=80)
317-
-> Custom Scan (ChunkDispatch) (cost=0.00..0.03 rows=2 width=80)
318-
-> Values Scan on "*VALUES*" (cost=0.00..0.03 rows=2 width=80)
313+
QUERY PLAN
314+
---------------------------------------------
315+
Custom Scan (HypertableInsert)
316+
-> Insert on "3dim"
317+
-> Custom Scan (ChunkDispatch)
318+
-> Values Scan on "*VALUES*"
319319
(4 rows)
320320

321-
EXPLAIN
321+
EXPLAIN (COSTS FALSE)
322322
WITH "3dim_insert" AS (
323323
INSERT INTO "3dim" VALUES('2017-01-21T09:01:44', 19.3, 'black', 'la') RETURNING time, temp
324324
), regular_insert AS (
325325
INSERT INTO regular_table VALUES('2017-01-21T10:00:51', 14.3) RETURNING time, temp
326326
) INSERT INTO "1dim" (SELECT time, temp FROM "3dim_insert" UNION SELECT time, temp FROM regular_insert);
327-
QUERY PLAN
328-
---------------------------------------------------------------------------------------------------
329-
Custom Scan (HypertableInsert) (cost=0.09..0.12 rows=2 width=16)
330-
-> Insert on "1dim" (cost=0.09..0.12 rows=2 width=16)
327+
QUERY PLAN
328+
------------------------------------------------------------------------------
329+
Custom Scan (HypertableInsert)
330+
-> Insert on "1dim"
331331
CTE 3dim_insert
332-
-> Custom Scan (HypertableInsert) (cost=0.00..0.01 rows=1 width=80)
333-
-> Insert on "3dim" (cost=0.00..0.01 rows=1 width=80)
334-
-> Custom Scan (ChunkDispatch) (cost=0.00..0.01 rows=1 width=80)
335-
-> Result (cost=0.00..0.01 rows=1 width=80)
332+
-> Custom Scan (HypertableInsert)
333+
-> Insert on "3dim"
334+
-> Custom Scan (ChunkDispatch)
335+
-> Result
336336
CTE regular_insert
337-
-> Insert on regular_table (cost=0.00..0.01 rows=1 width=16)
338-
-> Result (cost=0.00..0.01 rows=1 width=16)
339-
-> Custom Scan (ChunkDispatch) (cost=0.07..0.09 rows=2 width=16)
340-
-> Unique (cost=0.07..0.09 rows=2 width=16)
341-
-> Sort (cost=0.07..0.08 rows=2 width=16)
337+
-> Insert on regular_table
338+
-> Result
339+
-> Custom Scan (ChunkDispatch)
340+
-> Unique
341+
-> Sort
342342
Sort Key: "3dim_insert"."time", "3dim_insert".temp
343-
-> Append (cost=0.00..0.06 rows=2 width=16)
344-
-> CTE Scan on "3dim_insert" (cost=0.00..0.02 rows=1 width=16)
345-
-> CTE Scan on regular_insert (cost=0.00..0.02 rows=1 width=16)
343+
-> Append
344+
-> CTE Scan on "3dim_insert"
345+
-> CTE Scan on regular_insert
346346
(17 rows)
347347

348348
-- test prepared statement INSERT
@@ -401,7 +401,7 @@ SELECT create_hypertable('"smallinttime_err"', 'time', chunk_time_interval=>6553
401401

402402
(1 row)
403403

404-
--make sure date inserts work even when the timezone changes the
404+
--make sure date inserts work even when the timezone changes the
405405
CREATE TABLE hyper_date(time date, temp float);
406406
SELECT create_hypertable('"hyper_date"', 'time');
407407
NOTICE: Adding NOT NULL constraint to time column time (NULL time values not allowed)
@@ -413,7 +413,7 @@ NOTICE: Adding NOT NULL constraint to time column time (NULL time values not al
413413
SET timezone=+1;
414414
INSERT INTO "hyper_date" VALUES('2011-01-26', 22.5);
415415
RESET timezone;
416-
--make sure timestamp inserts work even when the timezone changes the
416+
--make sure timestamp inserts work even when the timezone changes the
417417
SET timezone = 'UTC';
418418
CREATE TABLE "test_tz"(time timestamp PRIMARY KEY, temp float);
419419
SELECT create_hypertable('"test_tz"', 'time', chunk_time_interval=> INTERVAL '1 day');

test/expected/sql_query_results_optimized.out

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ SELECT date_trunc('second', time) t, avg(series_0), min(series_1), avg(series_2)
150150

151151
--test that when index on time used by constraint, still works correctly
152152
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
158158
LIMIT 2;
159159
QUERY PLAN
160160
-----------------------------------------------------------------------------------------------------------
@@ -170,11 +170,11 @@ LIMIT 2;
170170
Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
171171
(10 rows)
172172

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
178178
LIMIT 2;
179179
t | avg | min | avg
180180
--------------------------+-------+-------+------------------
@@ -235,7 +235,7 @@ SELECT date_trunc('minute', time) t, avg(series_0), min(series_1), avg(series_2)
235235
Wed Dec 31 21:32:00 1969 | 19949.5 | 29920 | 141.242685621416
236236
(2 rows)
237237

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)
239239
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
240240
QUERY PLAN
241241
------------------------------------------------------------------------------------------
@@ -249,15 +249,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
249249
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
250250
(8 rows)
251251

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)
253253
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
254254
t | avg | min | avg
255255
--------------------------+---------+-------+------------------
256256
Wed Dec 31 21:33:00 1969 | 19990 | 29980 | 141.385994856058
257257
Wed Dec 31 21:32:00 1969 | 19949.5 | 29920 | 141.242685621416
258258
(2 rows)
259259

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)
261261
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
262262
QUERY PLAN
263263
-------------------------------------------------------------------------------------------------------------------------------------------
@@ -271,15 +271,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
271271
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
272272
(8 rows)
273273

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
275275
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
280280
(2 rows)
281281

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)
283283
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
284284
QUERY PLAN
285285
-----------------------------------------------------------------------------------------------------------------
@@ -293,15 +293,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
293293
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
294294
(8 rows)
295295

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
297297
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
302302
(2 rows)
303303

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)
305305
FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
306306
QUERY PLAN
307307
-------------------------------------------------------------------------------------------------------------------------------------------
@@ -315,15 +315,15 @@ FROM hyper_1 GROUP BY t ORDER BY t DESC limit 2;
315315
-> Index Scan using _hyper_1_1_chunk_time_plain on _hyper_1_1_chunk
316316
(8 rows)
317317

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
319319
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
324324
(2 rows)
325325

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)
327327
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
328328
QUERY PLAN
329329
---------------------------------------------------------------------------------------------
@@ -337,15 +337,15 @@ FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
337337
-> Index Scan using _hyper_2_2_chunk_time_plain_tz on _hyper_2_2_chunk
338338
(8 rows)
339339

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)
341341
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
342342
t | avg | min | avg
343343
------------------------------+---------+-------+------------------
344344
Wed Dec 31 21:33:00 1969 PST | 19990 | 29980 | 141.385994856058
345345
Wed Dec 31 21:32:00 1969 PST | 19949.5 | 29920 | 141.242685621416
346346
(2 rows)
347347

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)
349349
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
350350
QUERY PLAN
351351
-------------------------------------------------------------------------------------------------------------------------
@@ -359,15 +359,15 @@ FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
359359
-> Index Scan using _hyper_2_2_chunk_time_plain_tz on _hyper_2_2_chunk
360360
(8 rows)
361361

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)
363363
FROM hyper_1_tz GROUP BY t ORDER BY t DESC limit 2;
364364
t | avg | min | avg
365365
--------------------------+---------+-------+------------------
366366
Wed Dec 31 21:33:00 1969 | 19990 | 29980 | 141.385994856058
367367
Wed Dec 31 21:32:00 1969 | 19949.5 | 29920 | 141.242685621416
368368
(2 rows)
369369

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)
371371
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
372372
QUERY PLAN
373373
----------------------------------------------------------------------------------------------
@@ -383,15 +383,15 @@ FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
383383
-> Index Scan using _hyper_3_5_chunk_time_plain_int on _hyper_3_5_chunk
384384
(10 rows)
385385

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)
387387
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
388388
t | avg | min | avg
389389
-------+---------+-------+------------------
390390
20000 | 20000 | 30000 | 141.42135623731
391391
19990 | 19994.5 | 29990 | 141.401909099017
392392
(2 rows)
393393

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)
395395
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
396396
QUERY PLAN
397397
----------------------------------------------------------------------------------------------
@@ -407,7 +407,7 @@ FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
407407
-> Index Scan using _hyper_3_5_chunk_time_plain_int on _hyper_3_5_chunk
408408
(10 rows)
409409

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)
411411
FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
412412
t | avg | min | avg
413413
-------+---------+-------+------------------
@@ -417,11 +417,11 @@ FROM hyper_1_int GROUP BY t ORDER BY t DESC limit 2;
417417

418418
--plain tables shouldnt be optimized by default
419419
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
425425
LIMIT 2;
426426
QUERY PLAN
427427
-----------------------------------------------------------------------------------------------------------
@@ -436,11 +436,11 @@ LIMIT 2;
436436
Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
437437
(9 rows)
438438

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
444444
LIMIT 2;
445445
t | avg | min | avg
446446
------------------------------+-------+-------+------------------
@@ -452,11 +452,11 @@ LIMIT 2;
452452
BEGIN;
453453
SET LOCAL timescaledb.optimize_non_hypertables = 'on';
454454
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
460460
LIMIT 2;
461461
QUERY PLAN
462462
-----------------------------------------------------------------------------------------------
@@ -467,11 +467,11 @@ BEGIN;
467467
Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
468468
(5 rows)
469469

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
475475
LIMIT 2;
476476
t | avg | min | avg
477477
------------------------------+-------+-------+------------------

0 commit comments

Comments
 (0)