9
9
-- emitted plan. This is intended to be used when the structure of the
10
10
-- plan is important, but not the specific chunks scanned nor the
11
11
-- number of heap fetches, rows, loops, etc.
12
+ create function anonymize(ln text) returns text language plpgsql as
13
+ $$
14
+ begin
15
+ ln := regexp_replace(ln, '_hyper_\d+_\d+_chunk', '_hyper_I_N_chunk', 1, 0);
16
+ ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N');
17
+ ln := regexp_replace(ln, 'Workers Launched: \d+', 'Workers Launched: N');
18
+ ln := regexp_replace(ln, 'actual rows=\d+ loops=\d+', 'actual rows=N loops=N');
19
+
20
+ if trim(both from ln) like 'Array: %' then
21
+ ln := regexp_replace(ln, 'hits=\d+', 'hits=N');
22
+ ln := regexp_replace(ln, 'misses=\d+', 'misses=N');
23
+ ln := regexp_replace(ln, 'count=\d+', 'count=N');
24
+ ln := regexp_replace(ln, 'calls=\d+', 'calls=N');
25
+ end if;
26
+ return ln;
27
+ end
28
+ $$;
12
29
create function explain_analyze_anonymize(text) returns setof text
13
30
language plpgsql as
14
31
$$
@@ -18,17 +35,11 @@ begin
18
35
for ln in
19
36
execute format('explain (analyze, costs off, summary off, timing off, decompress_cache_stats) %s', $1)
20
37
loop
21
- if trim(both from ln) like 'Group Key:%' then
22
- continue;
23
- end if;
24
- ln := regexp_replace(ln, 'Array Cache Hits: \d+', 'Array Cache Hits: N');
25
- ln := regexp_replace(ln, 'Array Cache Misses: \d+', 'Array Cache Misses: N');
26
- ln := regexp_replace(ln, 'Array Cache Evictions: \d+', 'Array Cache Evictions: N');
27
- ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N');
28
- ln := regexp_replace(ln, 'Workers Launched: \d+', 'Workers Launched: N');
29
- ln := regexp_replace(ln, 'actual rows=\d+ loops=\d+', 'actual rows=N loops=N');
30
- ln := regexp_replace(ln, '_hyper_\d+_\d+_chunk', '_hyper_I_N_chunk', 1, 0);
31
- return next ln;
38
+ if trim(both from ln) like 'Group Key:%' then
39
+ continue;
40
+ end if;
41
+
42
+ return next anonymize(ln);
32
43
end loop;
33
44
end;
34
45
$$;
@@ -41,14 +52,10 @@ begin
41
52
for ln in
42
53
execute format('explain (costs off, summary off, timing off) %s', $1)
43
54
loop
44
- ln := regexp_replace(ln, 'Array Cache Hits: \d+', 'Array Cache Hits: N');
45
- ln := regexp_replace(ln, 'Array Cache Misses: \d+', 'Array Cache Misses: N');
46
- ln := regexp_replace(ln, 'Array Cache Evictions: \d+', 'Array Cache Evictions: N');
47
- ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N');
48
- ln := regexp_replace(ln, 'Workers Launched: \d+', 'Workers Launched: N');
49
- ln := regexp_replace(ln, 'actual rows=\d+ loops=\d+', 'actual rows=N loops=N');
50
- ln := regexp_replace(ln, '_hyper_\d+_\d+_chunk', '_hyper_I_N_chunk', 1, 0);
51
- return next ln;
55
+ if trim(both from ln) like 'Group Key:%' then
56
+ continue;
57
+ end if;
58
+ return next anonymize(ln);
52
59
end loop;
53
60
end;
54
61
$$;
@@ -101,11 +108,8 @@ $$, :'chunk'));
101
108
Scankey: (device < 4)
102
109
Vectorized Filter: (location = 2)
103
110
Rows Removed by Filter: 16
104
- Array Cache Hits: N
105
- Array Cache Misses: N
106
- Array Cache Evictions: N
107
- Array Decompressions: 3
108
- (9 rows)
111
+ Array: cache misses=N, decompress count=N calls=N
112
+ (6 rows)
109
113
110
114
-- Save away all data from the chunk so that we can compare.
111
115
create table saved as select * from :chunk;
@@ -136,11 +140,8 @@ $$, :'chunk'));
136
140
-> Custom Scan (ColumnarScan) on _hyper_I_N_chunk (actual rows=N loops=N)
137
141
Vectorized Filter: (humidity > '110'::double precision)
138
142
Rows Removed by Filter: 204
139
- Array Cache Hits: N
140
- Array Cache Misses: N
141
- Array Cache Evictions: N
142
- Array Decompressions: 30
143
- (8 rows)
143
+ Array: cache misses=N, decompress count=N calls=N
144
+ (5 rows)
144
145
145
146
select count(*) from :chunk where humidity > 110;
146
147
count
@@ -159,11 +160,8 @@ $$, :'chunk'));
159
160
-> Custom Scan (ColumnarScan) on _hyper_I_N_chunk (actual rows=N loops=N)
160
161
Vectorized Filter: (humidity > '50'::double precision)
161
162
Rows Removed by Filter: 87
162
- Array Cache Hits: N
163
- Array Cache Misses: N
164
- Array Cache Evictions: N
165
- Array Decompressions: 30
166
- (8 rows)
163
+ Array: cache misses=N, decompress count=N calls=N
164
+ (5 rows)
167
165
168
166
select lhs.count, rhs.count
169
167
from (select count(*) from :chunk where humidity > 50) lhs,
@@ -194,11 +192,8 @@ $$, :'chunk'));
194
192
-> Custom Scan (ColumnarScan) on _hyper_I_N_chunk (actual rows=N loops=N)
195
193
Filter: (temp > '50'::numeric)
196
194
Rows Removed by Filter: 204
197
- Array Cache Hits: N
198
- Array Cache Misses: N
199
- Array Cache Evictions: N
200
- Array Decompressions: 30
201
- (8 rows)
195
+ Array: cache misses=N, decompress count=N calls=N
196
+ (5 rows)
202
197
203
198
select count(*) from :chunk where temp > 50;
204
199
count
@@ -216,11 +211,8 @@ $$, :'chunk'));
216
211
-> Custom Scan (ColumnarScan) on _hyper_I_N_chunk (actual rows=N loops=N)
217
212
Filter: (temp > '20'::numeric)
218
213
Rows Removed by Filter: 98
219
- Array Cache Hits: N
220
- Array Cache Misses: N
221
- Array Cache Evictions: N
222
- Array Decompressions: 30
223
- (8 rows)
214
+ Array: cache misses=N, decompress count=N calls=N
215
+ (5 rows)
224
216
225
217
select lhs.count, rhs.count
226
218
from (select count(*) from :chunk where temp > 20) lhs,
@@ -251,11 +243,8 @@ select count(*) from :chunk where humidity > 40 and temp > 20;
251
243
Filter: (temp > '20'::numeric)
252
244
Rows Removed by Filter: 132
253
245
Vectorized Filter: (humidity > '40'::double precision)
254
- Array Cache Hits: 0
255
- Array Cache Misses: 30
256
- Array Cache Evictions: 0
257
- Array Decompressions: 60
258
- (9 rows)
246
+ Array: cache misses=30, decompress count=60 calls=165
247
+ (6 rows)
259
248
260
249
select count(*) from :chunk where humidity > 40 and temp > 20;
261
250
count
@@ -284,11 +273,8 @@ $$, :'chunk'));
284
273
Rows Removed by Filter: 3
285
274
Scankey: (device = 3)
286
275
Vectorized Filter: (humidity > '40'::double precision)
287
- Array Cache Hits: N
288
- Array Cache Misses: N
289
- Array Cache Evictions: N
290
- Array Decompressions: 2
291
- (10 rows)
276
+ Array: cache misses=N, decompress count=N calls=N
277
+ (7 rows)
292
278
293
279
select count(*) from :chunk where humidity > 40 and temp > 20 and device = 3;
294
280
count
@@ -318,11 +304,8 @@ $$, :'chunk'));
318
304
-> Seq Scan on _hyper_I_N_chunk (actual rows=N loops=N)
319
305
Filter: (device < 4)
320
306
Rows Removed by Filter: 184
321
- Array Cache Hits: N
322
- Array Cache Misses: N
323
- Array Cache Evictions: N
324
- Array Decompressions: 96
325
- (11 rows)
307
+ Array: cache misses=N, decompress count=N calls=N
308
+ (8 rows)
326
309
327
310
drop table readings;
328
311
drop table saved;
0 commit comments