@@ -213,23 +213,23 @@ ALTER TABLE hist_tbl INJECT STATISTICS '[
213213----
214214
215215# Test histogram-based range queries with canary stats
216- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=1.0
216+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=true
217217SELECT score FROM hist_tbl WHERE score BETWEEN 50 AND 200
218218----
219219select
220220 ├── columns: score:2(int!null)
221- ├── stats: [rows=441.766 , distinct(2)=14.9061 , null(2)=0]
222- │ histogram(2)= 0 0 91.011 45 44.662 0.45113
221+ ├── stats: [rows=490.851 , distinct(2)=16.576 , null(2)=0]
222+ │ histogram(2)= 0 0 101.12 50 49.624 0.50125
223223 │ <--- 49 -------- 100 --------- 200 -
224224 ├── scan hist_tbl
225225 │ ├── columns: score:2(int)
226- │ └── stats: [rows=1800 , distinct(2)=90 , null(2)=0]
227- │ histogram(2)= 0 18 162 45 180 27 270 36
226+ │ └── stats: [rows=2000 , distinct(2)=100 , null(2)=0]
227+ │ histogram(2)= 0 20 180 50 200 30 300 40
228228 │ <--- 10 ----- 100 ----- 500 ----- 1000
229229 └── filters
230230 └── (score:2 >= 50) AND (score:2 <= 200) [type=bool, outer=(2), constraints=(/2: [/50 - /200]; tight)]
231231
232- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=0.0
232+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=false
233233SELECT score FROM hist_tbl WHERE score BETWEEN 50 AND 200
234234----
235235select
@@ -246,24 +246,24 @@ select
246246 └── (score:2 >= 50) AND (score:2 <= 200) [type=bool, outer=(2), constraints=(/2: [/50 - /200]; tight)]
247247
248248# Test string histogram with equality predicates
249- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=1.0
249+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=true
250250SELECT category FROM hist_tbl WHERE category = 'electronics'
251251----
252252select
253253 ├── columns: category:3(string!null)
254- ├── stats: [rows=334.711 , distinct(3)=1, null(3)=0]
255- │ histogram(3)= 0 225
254+ ├── stats: [rows=371.747 , distinct(3)=1, null(3)=0]
255+ │ histogram(3)= 0 250
256256 │ <--- 'electronics'
257257 ├── fd: ()-->(3)
258258 ├── scan hist_tbl
259259 │ ├── columns: category:3(string)
260- │ └── stats: [rows=1800 , distinct(3)=7 , null(3)=4 ]
261- │ histogram(3)= 0 4 0 225 270 180 135 162 90 144
262- │ <--- NULL --- 'electronics' ----- 'home' ----- 'sports' ---- 'toys'
260+ │ └── stats: [rows=2000 , distinct(3)=8 , null(3)=5 ]
261+ │ histogram(3)= 0 5 0 250 300 200 150 180 100 160
262+ │ <--- NULL --- 'electronics' ----- 'home' ----- 'sports' ----- 'toys'
263263 └── filters
264264 └── category:3 = 'electronics' [type=bool, outer=(3), constraints=(/3: [/'electronics' - /'electronics']; tight), fd=()-->(3)]
265265
266- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=0.0
266+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=false
267267SELECT category FROM hist_tbl WHERE category = 'electronics'
268268----
269269select
@@ -281,24 +281,24 @@ select
281281 └── category:3 = 'electronics' [type=bool, outer=(3), constraints=(/3: [/'electronics' - /'electronics']; tight), fd=()-->(3)]
282282
283283# Test decimal histogram with range queries
284- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=1.0
284+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=true
285285SELECT price FROM hist_tbl WHERE price > 50.0 AND price <= 500.0
286286----
287287select
288288 ├── columns: price:4(decimal!null)
289289 ├── immutable
290- ├── stats: [rows=825.185 , distinct(4)=110.992 , null(4)=0]
291- │ histogram(4)= 0 0 199.96 72 120 0
292- │ <--- 50.0 -------- 99.99 ----- 500.0
290+ ├── stats: [rows=916.873 , distinct(4)=123.213 , null(4)=0]
291+ │ histogram(4)= 0 0 222.18 80 133.34 0
292+ │ <--- 50.0 -------- 99.99 -------- 500.0
293293 ├── scan hist_tbl
294294 │ ├── columns: price:4(decimal)
295- │ └── stats: [rows=1800 , distinct(4)=450 , null(4)=9 ]
296- │ histogram(4)= 0 9 0 90 360 72 270 54
295+ │ └── stats: [rows=2000 , distinct(4)=500 , null(4)=10 ]
296+ │ histogram(4)= 0 10 0 100 400 80 300 60
297297 │ <--- NULL --- 9.99 ----- 99.99 ----- 999.99
298298 └── filters
299299 └── (price:4 > 50.0) AND (price:4 <= 500.0) [type=bool, outer=(4), immutable, constraints=(/4: (/50.0 - /500.0]; tight)]
300300
301- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=0.0
301+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=false
302302SELECT price FROM hist_tbl WHERE price > 50.0 AND price <= 500.0
303303----
304304select
@@ -316,32 +316,32 @@ select
316316 └── (price:4 > 50.0) AND (price:4 <= 500.0) [type=bool, outer=(4), immutable, constraints=(/4: (/50.0 - /500.0]; tight)]
317317
318318# Test combined histogram and non-histogram columns
319- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=1.0
319+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=true
320320SELECT * FROM hist_tbl WHERE score > 100 AND category LIKE 'h%'
321321----
322322select
323323 ├── columns: id:1(int!null) score:2(int!null) category:3(string!null) price:4(decimal)
324- ├── stats: [rows=233.644 , distinct(2)=47 , null(2)=0, distinct(3)=1.53618, null(3)=0, distinct(2,3)=72.2006 , null(2,3)=0]
325- │ histogram(2)= 0 0 81.98 12.297 122.97 16.396
326- │ <--- 100 ------- 500 --------- 1000
327- │ histogram(3)= 0 0 39.018 180 6.9286 0
324+ ├── stats: [rows=259.497 , distinct(2)=52 , null(2)=0, distinct(3)=1.53618, null(3)=0, distinct(2,3)=79.8815 , null(2,3)=0]
325+ │ histogram(2)= 0 0 91.052 13.658 136.58 18.21
326+ │ <--- 100 -------- 500 --------- 1000
327+ │ histogram(3)= 0 0 43.354 200 7.6984 0
328328 │ <--- 'h' -------- 'home' -------- 'i'
329329 ├── key: (1)
330330 ├── fd: (1)-->(2-4)
331331 ├── scan hist_tbl
332332 │ ├── columns: id:1(int!null) score:2(int) category:3(string) price:4(decimal)
333- │ ├── stats: [rows=1800 , distinct(1)=1800 , null(1)=0, distinct(2)=90 , null(2)=0, distinct(3)=7 , null(3)=4 , distinct(2,3)=630 , null(2,3)=0]
334- │ │ histogram(2)= 0 18 162 45 180 27 270 36
333+ │ ├── stats: [rows=2000 , distinct(1)=2000 , null(1)=0, distinct(2)=100 , null(2)=0, distinct(3)=8 , null(3)=5 , distinct(2,3)=800 , null(2,3)=0]
334+ │ │ histogram(2)= 0 20 180 50 200 30 300 40
335335 │ │ <--- 10 ----- 100 ----- 500 ----- 1000
336- │ │ histogram(3)= 0 4 0 225 270 180 135 162 90 144
337- │ │ <--- NULL --- 'electronics' ----- 'home' ----- 'sports' ---- 'toys'
336+ │ │ histogram(3)= 0 5 0 250 300 200 150 180 100 160
337+ │ │ <--- NULL --- 'electronics' ----- 'home' ----- 'sports' ----- 'toys'
338338 │ ├── key: (1)
339339 │ └── fd: (1)-->(2-4)
340340 └── filters
341341 ├── score:2 > 100 [type=bool, outer=(2), constraints=(/2: [/101 - ]; tight)]
342342 └── category:3 LIKE 'h%' [type=bool, outer=(3), constraints=(/3: [/'h' - /'i'); tight)]
343343
344- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=0.0
344+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=false
345345SELECT * FROM hist_tbl WHERE score > 100 AND category LIKE 'h%'
346346----
347347select
@@ -367,28 +367,28 @@ select
367367 └── category:3 LIKE 'h%' [type=bool, outer=(3), constraints=(/3: [/'h' - /'i'); tight)]
368368
369369# Test histogram with aggregations
370- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=1.0
370+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=true
371371SELECT category, count(*), avg(score), max(price) FROM hist_tbl GROUP BY category
372372----
373373group-by (hash)
374374 ├── columns: category:3(string) count:7(int!null) avg:8(decimal) max:9(decimal)
375375 ├── grouping columns: category:3(string)
376- ├── stats: [rows=7 , distinct(3)=7 , null(3)=1]
376+ ├── stats: [rows=8 , distinct(3)=8 , null(3)=1]
377377 ├── key: (3)
378378 ├── fd: (3)-->(7-9)
379379 ├── scan hist_tbl
380380 │ ├── columns: score:2(int) category:3(string) price:4(decimal)
381- │ └── stats: [rows=1800 , distinct(3)=7 , null(3)=4 ]
382- │ histogram(3)= 0 4 0 225 270 180 135 162 90 144
383- │ <--- NULL --- 'electronics' ----- 'home' ----- 'sports' ---- 'toys'
381+ │ └── stats: [rows=2000 , distinct(3)=8 , null(3)=5 ]
382+ │ histogram(3)= 0 5 0 250 300 200 150 180 100 160
383+ │ <--- NULL --- 'electronics' ----- 'home' ----- 'sports' ----- 'toys'
384384 └── aggregations
385385 ├── count-rows [as=count_rows:7, type=int]
386386 ├── avg [as=avg:8, type=decimal, outer=(2)]
387387 │ └── score:2 [type=int]
388388 └── max [as=max:9, type=decimal, outer=(4)]
389389 └── price:4 [type=decimal]
390390
391- opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-fraction=0.0
391+ opt stats-as-of=(2018-01-01 13:00:30.00000+00:00) canary-stats=false
392392SELECT category, count(*), avg(score), max(price) FROM hist_tbl GROUP BY category
393393----
394394group-by (hash)
0 commit comments