3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # Testing the compound-SELECT merge algorithm to ensure that it works
13 # when it tries to balance the merge tree.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
24 load_static_extension db series
27 optimization_control db all on
30 SELECT value FROM generate_series(1,35,3)
32 SELECT value FROM generate_series(10,30,4)
34 SELECT value FROM generate_series(20,50,5)
36 SELECT value FROM generate_series(30,60,6)
38 SELECT value FROM generate_series(1,50,7)
40 SELECT value FROM generate_series(10,80,8)
42 SELECT v FROM data ORDER BY v;
43 } {1 1 4 7 8 10 10 10 13 14 15 16 18 18 19 20 22 22 22 25 25 26 26 28 29 30 30 30 31 34 34 35 36 36 40 42 42 43 45 48 50 50 50 54 58 60 66 74}
46 SELECT value FROM generate_series(1,35,3)
48 SELECT value FROM generate_series(10,30,4)
50 SELECT value FROM generate_series(20,50,5)
52 SELECT value FROM generate_series(30,60,6)
54 SELECT value FROM generate_series(1,50,7)
56 SELECT value FROM generate_series(10,80,8)
58 SELECT v FROM data ORDER BY v;
63 | `--MERGE (UNION ALL)
65 | | `--MERGE (UNION ALL)
67 | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
69 | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
71 | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
75 | `--MERGE (UNION ALL)
77 | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
79 | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
81 `--SCAN generate_series VIRTUAL TABLE INDEX 23:
84 # Same test with the blanced-merge optimization
85 # disabled. Should give the exact same answer.
87 optimization_control db balanced-merge off
91 SELECT value FROM generate_series(1,35,3)
93 SELECT value FROM generate_series(10,30,4)
95 SELECT value FROM generate_series(20,50,5)
97 SELECT value FROM generate_series(30,60,6)
99 SELECT value FROM generate_series(1,50,7)
101 SELECT value FROM generate_series(10,80,8)
103 SELECT v FROM data ORDER BY v;
104 } {1 1 4 7 8 10 10 10 13 14 15 16 18 18 19 20 22 22 22 25 25 26 26 28 29 30 30 30 31 34 34 35 36 36 40 42 42 43 45 48 50 50 50 54 58 60 66 74}
107 SELECT value FROM generate_series(1,35,3)
109 SELECT value FROM generate_series(10,30,4)
111 SELECT value FROM generate_series(20,50,5)
113 SELECT value FROM generate_series(30,60,6)
115 SELECT value FROM generate_series(1,50,7)
117 SELECT value FROM generate_series(10,80,8)
119 SELECT v FROM data ORDER BY v;
124 | `--MERGE (UNION ALL)
126 | | `--MERGE (UNION ALL)
128 | | | `--MERGE (UNION ALL)
130 | | | | `--MERGE (UNION ALL)
132 | | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
134 | | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
136 | | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
138 | | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
140 | `--SCAN generate_series VIRTUAL TABLE INDEX 23:
142 `--SCAN generate_series VIRTUAL TABLE INDEX 23: