@@ -71,16 +71,39 @@ psql:include/append.sql:45: NOTICE: Stable function now_s() called!
71
71
------+------+---------
72
72
(0 rows)
73
73
74
+ --query should exclude all chunks and be a MergeAppend
75
+ EXPLAIN (costs off)
76
+ SELECT * FROM append_test WHERE time > now_s() + '1 month'
77
+ ORDER BY time DESC limit 1;
78
+ psql:include/append.sql:50: NOTICE: Stable function now_s() called!
79
+ psql:include/append.sql:50: NOTICE: Stable function now_s() called!
80
+ psql:include/append.sql:50: NOTICE: Stable function now_s() called!
81
+ psql:include/append.sql:50: NOTICE: Stable function now_s() called!
82
+ QUERY PLAN
83
+ ----------------------------------------------------------------------------------------
84
+ Limit
85
+ -> Merge Append
86
+ Sort Key: append_test."time" DESC
87
+ -> Index Scan using append_test_time_idx on append_test
88
+ Index Cond: ("time" > (now_s() + '@ 1 mon'::interval))
89
+ -> Index Scan using _hyper_1_1_chunk_append_test_time_idx on _hyper_1_1_chunk
90
+ Index Cond: ("time" > (now_s() + '@ 1 mon'::interval))
91
+ -> Index Scan using _hyper_1_2_chunk_append_test_time_idx on _hyper_1_2_chunk
92
+ Index Cond: ("time" > (now_s() + '@ 1 mon'::interval))
93
+ -> Index Scan using _hyper_1_3_chunk_append_test_time_idx on _hyper_1_3_chunk
94
+ Index Cond: ("time" > (now_s() + '@ 1 mon'::interval))
95
+ (11 rows)
96
+
74
97
-- when optimized, the plan should be a constraint-aware append and
75
98
-- cover only one chunk. It should be a backward index scan due to
76
99
-- descending index on time. Should also skip the main table, since it
77
100
-- cannot hold tuples
78
101
EXPLAIN (costs off)
79
102
SELECT * FROM append_test WHERE time > now_s() - interval '2 months';
80
- psql:include/append.sql:52 : NOTICE: Stable function now_s() called!
81
- psql:include/append.sql:52 : NOTICE: Stable function now_s() called!
82
- psql:include/append.sql:52 : NOTICE: Stable function now_s() called!
83
- psql:include/append.sql:52 : NOTICE: Stable function now_s() called!
103
+ psql:include/append.sql:57 : NOTICE: Stable function now_s() called!
104
+ psql:include/append.sql:57 : NOTICE: Stable function now_s() called!
105
+ psql:include/append.sql:57 : NOTICE: Stable function now_s() called!
106
+ psql:include/append.sql:57 : NOTICE: Stable function now_s() called!
84
107
QUERY PLAN
85
108
----------------------------------------------------------------------------------
86
109
Append
@@ -96,13 +119,13 @@ psql:include/append.sql:52: NOTICE: Stable function now_s() called!
96
119
97
120
-- the expected output should be the same as the non-optimized query
98
121
SELECT * FROM append_test WHERE time > now_s() - interval '2 months';
99
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
100
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
101
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
102
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
103
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
104
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
105
- psql:include/append.sql:55 : NOTICE: Stable function now_s() called!
122
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
123
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
124
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
125
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
126
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
127
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
128
+ psql:include/append.sql:60 : NOTICE: Stable function now_s() called!
106
129
time | temp | colorid
107
130
--------------------------+------+---------
108
131
Tue Aug 22 09:18:22 2017 | 34.1 | 3
@@ -113,10 +136,10 @@ psql:include/append.sql:55: NOTICE: Stable function now_s() called!
113
136
EXPLAIN (costs off)
114
137
SELECT * FROM append_test WHERE time > now_s() - interval '2 months'
115
138
ORDER BY time LIMIT 3;
116
- psql:include/append.sql:61 : NOTICE: Stable function now_s() called!
117
- psql:include/append.sql:61 : NOTICE: Stable function now_s() called!
118
- psql:include/append.sql:61 : NOTICE: Stable function now_s() called!
119
- psql:include/append.sql:61 : NOTICE: Stable function now_s() called!
139
+ psql:include/append.sql:66 : NOTICE: Stable function now_s() called!
140
+ psql:include/append.sql:66 : NOTICE: Stable function now_s() called!
141
+ psql:include/append.sql:66 : NOTICE: Stable function now_s() called!
142
+ psql:include/append.sql:66 : NOTICE: Stable function now_s() called!
120
143
QUERY PLAN
121
144
-------------------------------------------------------------------------------------------------
122
145
Limit
@@ -135,14 +158,14 @@ psql:include/append.sql:61: NOTICE: Stable function now_s() called!
135
158
-- the expected output should be the same as the non-optimized query
136
159
SELECT * FROM append_test WHERE time > now_s() - interval '2 months'
137
160
ORDER BY time LIMIT 3;
138
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
139
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
140
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
141
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
142
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
143
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
144
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
145
- psql:include/append.sql:65 : NOTICE: Stable function now_s() called!
161
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
162
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
163
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
164
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
165
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
166
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
167
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
168
+ psql:include/append.sql:70 : NOTICE: Stable function now_s() called!
146
169
time | temp | colorid
147
170
--------------------------+------+---------
148
171
Tue Aug 22 09:18:22 2017 | 34.1 | 3
@@ -154,8 +177,8 @@ psql:include/append.sql:65: NOTICE: Stable function now_s() called!
154
177
EXPLAIN (costs off)
155
178
SELECT * FROM append_test WHERE time > now_i() - interval '2 months'
156
179
ORDER BY time;
157
- psql:include/append.sql:72 : NOTICE: Immutable function now_i() called!
158
- psql:include/append.sql:72 : NOTICE: Immutable function now_i() called!
180
+ psql:include/append.sql:77 : NOTICE: Immutable function now_i() called!
181
+ psql:include/append.sql:77 : NOTICE: Immutable function now_i() called!
159
182
QUERY PLAN
160
183
----------------------------------------------------------------------------------------------------
161
184
Sort
@@ -193,11 +216,11 @@ ORDER BY time;
193
216
194
217
SELECT * FROM append_test WHERE time > now_v() - interval '2 months'
195
218
ORDER BY time;
196
- psql:include/append.sql:83 : NOTICE: Volatile function now_v() called!
197
- psql:include/append.sql:83 : NOTICE: Volatile function now_v() called!
198
- psql:include/append.sql:83 : NOTICE: Volatile function now_v() called!
199
- psql:include/append.sql:83 : NOTICE: Volatile function now_v() called!
200
- psql:include/append.sql:83 : NOTICE: Volatile function now_v() called!
219
+ psql:include/append.sql:88 : NOTICE: Volatile function now_v() called!
220
+ psql:include/append.sql:88 : NOTICE: Volatile function now_v() called!
221
+ psql:include/append.sql:88 : NOTICE: Volatile function now_v() called!
222
+ psql:include/append.sql:88 : NOTICE: Volatile function now_v() called!
223
+ psql:include/append.sql:88 : NOTICE: Volatile function now_v() called!
201
224
time | temp | colorid
202
225
--------------------------+------+---------
203
226
Tue Aug 22 09:18:22 2017 | 34.1 | 3
@@ -209,14 +232,14 @@ PREPARE query_opt AS
209
232
SELECT * FROM append_test WHERE time > now_s() - interval '2 months'
210
233
ORDER BY time;
211
234
EXECUTE query_opt;
212
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
213
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
214
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
215
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
216
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
217
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
218
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
219
- psql:include/append.sql:91 : NOTICE: Stable function now_s() called!
235
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
236
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
237
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
238
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
239
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
240
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
241
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
242
+ psql:include/append.sql:96 : NOTICE: Stable function now_s() called!
220
243
time | temp | colorid
221
244
--------------------------+------+---------
222
245
Tue Aug 22 09:18:22 2017 | 34.1 | 3
@@ -243,13 +266,13 @@ SELECT date_trunc('year', time) t, avg(temp) FROM append_test
243
266
WHERE time > now_s() - interval '4 months'
244
267
GROUP BY t
245
268
ORDER BY t DESC;
246
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
247
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
248
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
249
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
250
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
251
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
252
- psql:include/append.sql:100 : NOTICE: Stable function now_s() called!
269
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
270
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
271
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
272
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
273
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
274
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
275
+ psql:include/append.sql:105 : NOTICE: Stable function now_s() called!
253
276
t | avg
254
277
--------------------------+------
255
278
Sun Jan 01 00:00:00 2017 | 28.5
@@ -261,10 +284,10 @@ SELECT date_trunc('year', time) t, avg(temp) FROM append_test
261
284
WHERE time > now_s() - interval '4 months'
262
285
GROUP BY t
263
286
ORDER BY t DESC;
264
- psql:include/append.sql:107 : NOTICE: Stable function now_s() called!
265
- psql:include/append.sql:107 : NOTICE: Stable function now_s() called!
266
- psql:include/append.sql:107 : NOTICE: Stable function now_s() called!
267
- psql:include/append.sql:107 : NOTICE: Stable function now_s() called!
287
+ psql:include/append.sql:112 : NOTICE: Stable function now_s() called!
288
+ psql:include/append.sql:112 : NOTICE: Stable function now_s() called!
289
+ psql:include/append.sql:112 : NOTICE: Stable function now_s() called!
290
+ psql:include/append.sql:112 : NOTICE: Stable function now_s() called!
268
291
QUERY PLAN
269
292
----------------------------------------------------------------------------------------------------
270
293
Sort
@@ -290,7 +313,7 @@ PREPARE query_param AS
290
313
SELECT * FROM append_test WHERE time > $1 ORDER BY time;
291
314
EXPLAIN (costs off)
292
315
EXECUTE query_param(now_s() - interval '2 months');
293
- psql:include/append.sql:116 : NOTICE: Stable function now_s() called!
316
+ psql:include/append.sql:121 : NOTICE: Stable function now_s() called!
294
317
QUERY PLAN
295
318
----------------------------------------------------------------------------------------------------
296
319
Sort
@@ -324,14 +347,14 @@ set enable_material = 'off';
324
347
EXPLAIN (costs off)
325
348
SELECT * FROM append_test a INNER JOIN join_test j ON (a.colorid = j.colorid)
326
349
WHERE a.time > now_s() - interval '3 hours' AND j.time > now_s() - interval '3 hours';
327
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
328
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
329
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
330
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
331
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
332
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
333
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
334
- psql:include/append.sql:136 : NOTICE: Stable function now_s() called!
350
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
351
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
352
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
353
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
354
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
355
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
356
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
357
+ psql:include/append.sql:141 : NOTICE: Stable function now_s() called!
335
358
QUERY PLAN
336
359
--------------------------------------------------------------------------------------------
337
360
Nested Loop
@@ -359,20 +382,20 @@ psql:include/append.sql:136: NOTICE: Stable function now_s() called!
359
382
-- result should be the same as when optimizations are turned off
360
383
SELECT * FROM append_test a INNER JOIN join_test j ON (a.colorid = j.colorid)
361
384
WHERE a.time > now_s() - interval '3 hours' AND j.time > now_s() - interval '3 hours';
362
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
363
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
364
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
365
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
366
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
367
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
368
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
369
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
370
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
371
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
372
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
373
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
374
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
375
- psql:include/append.sql:140 : NOTICE: Stable function now_s() called!
385
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
386
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
387
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
388
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
389
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
390
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
391
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
392
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
393
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
394
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
395
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
396
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
397
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
398
+ psql:include/append.sql:145 : NOTICE: Stable function now_s() called!
376
399
time | temp | colorid | time | temp | colorid
377
400
--------------------------+------+---------+--------------------------+------+---------
378
401
Tue Aug 22 09:18:22 2017 | 34.1 | 3 | Tue Aug 22 09:18:22 2017 | 23.1 | 3
0 commit comments