← Back
Editing: group_by_hypergraph.result
# # Bug#32980875: WL#14422: ASSERTION `FALSE' FAILED|SQL/BASIC_ROW_ITERATORS.H # CREATE TABLE t (x INTEGER); INSERT INTO t VALUES (1), (2), (3); ANALYZE TABLE t; Table Op Msg_type Msg_text test.t analyze status OK EXPLAIN FORMAT=TREE SELECT DISTINCT MIN(t2.x), t1.x FROM t t1 JOIN t t2 USING (x) GROUP BY t2.x; EXPLAIN -> Remove duplicates from input grouped on t.x, `MIN(t2.x)` -> Stream results -> Group aggregate: min(t2.x) -> Sort: t2.x -> Inner hash join (t1.x = t2.x) -> Table scan on t1 -> Hash -> Table scan on t2 DROP TABLE t; # # Bug #34670701 Too many ROLLUP rows with hypergraph # CREATE TABLE t1( a INT, b INT, c INT, d INT, e INT, PRIMARY KEY(a,b), KEY ix1 (c,d) ); INSERT INTO t1 VALUES (0,0,0,0,1), (1,0,1,0,1), (0,1,2,0,1), (2,0,2,0,1), (4,0,0,0,1); ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK EXPLAIN FORMAT=TREE SELECT a,c,d,sum(e) FROM t1 GROUP BY a,c,d WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Sort: t1.a, t1.c, t1.d (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT a,d,c,sum(e) FROM t1 GROUP BY a,d,c WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Sort: t1.a, t1.d, t1.c (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT c,a,d,sum(e) FROM t1 GROUP BY c,a,d WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Sort: t1.c, t1.a, t1.d (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT d,a,c,sum(e) FROM t1 GROUP BY d,a,c WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Sort: t1.d, t1.a, t1.c (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT c,d,b,sum(e) FROM t1 GROUP BY c,d,b WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Sort: t1.c, t1.d, t1.b (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT d,c,a,sum(e) FROM t1 GROUP BY d,c,a WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Sort: t1.d, t1.c, t1.a (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT b,a,sum(e) FROM t1 GROUP BY b,a WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=4.73) -> Sort: t1.b, t1.a (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT b,sum(e) FROM t1 GROUP BY b WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=3.24) -> Sort: t1.b (rows=5) -> Table scan on t1 (rows=5) EXPLAIN FORMAT=TREE SELECT c,sum(e) FROM t1 GROUP BY c WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=3.24) -> Index scan on t1 using ix1 (rows=5) SELECT c,sum(e) FROM t1 GROUP BY c WITH ROLLUP; c sum(e) 0 2 1 1 2 2 NULL 5 EXPLAIN FORMAT=TREE SELECT c,d,sum(e) FROM t1 GROUP BY c,d WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=4.73) -> Index scan on t1 using ix1 (rows=5) SELECT c,d,sum(e) FROM t1 GROUP BY c,d WITH ROLLUP; c d sum(e) 0 0 2 0 NULL 2 1 0 1 1 NULL 1 2 0 2 2 NULL 2 NULL NULL 5 EXPLAIN FORMAT=TREE SELECT c,d,a,sum(e) FROM t1 GROUP BY c,d,a WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=6.25) -> Index scan on t1 using ix1 (rows=5) SELECT c,d,a,sum(e) FROM t1 GROUP BY c,d,a WITH ROLLUP; c d a sum(e) 0 0 0 1 0 0 4 1 0 0 NULL 2 0 NULL NULL 2 1 0 1 1 1 0 NULL 1 1 NULL NULL 1 2 0 0 1 2 0 2 1 2 0 NULL 2 2 NULL NULL 2 NULL NULL NULL 5 EXPLAIN FORMAT=TREE SELECT c,d,a,b,sum(e) FROM t1 GROUP BY c,d,a,b WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=7.78) -> Index scan on t1 using ix1 (rows=5) SELECT c,d,a,b,sum(e) FROM t1 GROUP BY c,d,a,b WITH ROLLUP; c d a b sum(e) 0 0 0 0 1 0 0 0 NULL 1 0 0 4 0 1 0 0 4 NULL 1 0 0 NULL NULL 2 0 NULL NULL NULL 2 1 0 1 0 1 1 0 1 NULL 1 1 0 NULL NULL 1 1 NULL NULL NULL 1 2 0 0 1 1 2 0 0 NULL 1 2 0 2 0 1 2 0 2 NULL 1 2 0 NULL NULL 2 2 NULL NULL NULL 2 NULL NULL NULL NULL 5 EXPLAIN FORMAT=TREE SELECT a,sum(e) FROM t1 GROUP BY a WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=3.24) -> Index scan on t1 using PRIMARY (rows=5) SELECT a,sum(e) FROM t1 GROUP BY a WITH ROLLUP; a sum(e) 0 2 1 1 2 1 4 1 NULL 5 EXPLAIN FORMAT=TREE SELECT a,b,sum(e) FROM t1 GROUP BY a,b WITH ROLLUP; EXPLAIN -> Group aggregate with rollup: sum(t1.e) (rows=4.73) -> Index scan on t1 using PRIMARY (rows=5) SELECT a,b,sum(e) FROM t1 GROUP BY a,b WITH ROLLUP; a b sum(e) 0 0 1 0 1 1 0 NULL 2 1 0 1 1 NULL 1 2 0 1 2 NULL 1 4 0 1 4 NULL 1 NULL NULL 5 EXPLAIN FORMAT=TREE SELECT d,a,c,sum(e) FROM t1 GROUP BY d,a,c; EXPLAIN -> Group aggregate: sum(t1.e) (rows=2.24) -> Index scan on t1 using ix1 (rows=5) SELECT d,a,c,sum(e) FROM t1 GROUP BY d,a,c; d a c sum(e) 0 0 0 1 0 4 0 1 0 1 1 1 0 0 2 1 0 2 2 1 EXPLAIN FORMAT=TREE SELECT a,d,c,sum(e) FROM t1 GROUP BY a,d,c; EXPLAIN -> Group aggregate: sum(t1.e) (rows=2.24) -> Index scan on t1 using ix1 (rows=5) SELECT a,d,c,sum(e) FROM t1 GROUP BY a,d,c; a d c sum(e) 0 0 0 1 4 0 0 1 1 0 1 1 0 0 2 1 2 0 2 1 EXPLAIN FORMAT=TREE SELECT b,a,sum(e) FROM t1 GROUP BY b,a; EXPLAIN -> Group aggregate: sum(t1.e) (rows=2.24) -> Index scan on t1 using PRIMARY (rows=5) SELECT b,a,sum(e) FROM t1 GROUP BY b,a; b a sum(e) 0 0 1 1 0 1 0 1 1 0 2 1 0 4 1 EXPLAIN FORMAT=TREE SELECT a,c,e,sum(d) FROM t1 GROUP BY a,c,e; EXPLAIN -> Group aggregate: sum(t1.d) (rows=2.24) -> Sort: t1.a, t1.c, t1.e (rows=5) -> Table scan on t1 (rows=5) DROP TABLE t1; # # Bug #33968442: Hypergraph gives too high row estimates for GROUP BY # CREATE TABLE num10 (n INT); INSERT INTO num10 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); CREATE VIEW num1000 AS SELECT d1.n+d2.n*10+d3.n*100 n FROM num10 d1, num10 d2, num10 d3; CREATE TABLE t1( a INT, b INT, c INT, d INT, e INT, f INT, g INT, h INT, i INT, j INT, k INT, l INT, PRIMARY KEY(a,b), KEY ix1 (c,d), KEY ix2 (d,a,c), KEY ix3 (g,h,i,j), KEY ix4 (k,j,l), KEY ix5 (k,l) ); INSERT INTO t1 SELECT n/100,n%100,n%5,n%7,n%11,n%13,n%10,n%10,n%10,n%10,n%10,n%10 FROM num1000; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY a; EXPLAIN -> Group (no aggregates) (rows=11) (actual rows=11 loops=1) -> Covering index scan on t1 using PRIMARY (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c; EXPLAIN -> Group (no aggregates) (rows=5) (actual rows=5 loops=1) -> Covering index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY d,c; EXPLAIN -> Group (no aggregates) (rows=35) (actual rows=35 loops=1) -> Covering index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY d,a; EXPLAIN -> Group (no aggregates) (rows=77) (actual rows=77 loops=1) -> Covering index scan on t1 using ix2 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c,d,a; EXPLAIN -> Group (no aggregates) (rows=385) (actual rows=385 loops=1) -> Covering index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY d,a,c WITH ROLLUP; EXPLAIN -> Group (no aggregates) (rows=470) (actual rows=470 loops=1) -> Covering index scan on t1 using ix2 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c,d,a WITH ROLLUP; EXPLAIN -> Group (no aggregates) (rows=426) (actual rows=426 loops=1) -> Covering index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c,a,d WITH ROLLUP; EXPLAIN -> Group (no aggregates) (rows=423) (actual rows=446 loops=1) -> Sort: t1.c, t1.a, t1.d (rows=1000) (actual rows=1000 loops=1) -> Index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c,a; EXPLAIN -> Group (no aggregates) (rows=32.3) (actual rows=55 loops=1) -> Sort: t1.c, t1.a (rows=1000) (actual rows=1000 loops=1) -> Index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c,b; EXPLAIN -> Group (no aggregates) (rows=93) (actual rows=100 loops=1) -> Sort: t1.c, t1.b (rows=1000) (actual rows=1000 loops=1) -> Index scan on t1 using ix1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY e,f; EXPLAIN -> Group (no aggregates) (rows=320) (actual rows=143 loops=1) -> Sort: t1.e, t1.f (rows=1000) (actual rows=1000 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY g,h,i,j,k,l; EXPLAIN -> Group (no aggregates) (rows=46.8) (actual rows=10 loops=1) -> Sort: t1.g, t1.h, t1.i, t1.j, t1.k, t1.l (rows=1000) (actual rows=1000 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) ANALYZE TABLE t1 UPDATE HISTOGRAM ON a,b,c,d,e,f,g,h,i; Table Op Msg_type Msg_text test.t1 histogram status Histogram statistics created for column 'a'. test.t1 histogram status Histogram statistics created for column 'b'. test.t1 histogram status Histogram statistics created for column 'c'. test.t1 histogram status Histogram statistics created for column 'd'. test.t1 histogram status Histogram statistics created for column 'e'. test.t1 histogram status Histogram statistics created for column 'f'. test.t1 histogram status Histogram statistics created for column 'g'. test.t1 histogram status Histogram statistics created for column 'h'. test.t1 histogram status Histogram statistics created for column 'i'. ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY e; EXPLAIN -> Group (no aggregates) (rows=11) (actual rows=11 loops=1) -> Sort: t1.e (rows=1000) (actual rows=1000 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY e,f; EXPLAIN -> Group (no aggregates) (rows=64.8) (actual rows=143 loops=1) -> Sort: t1.e, t1.f (rows=1000) (actual rows=1000 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 WHERE b>95 GROUP BY e,f; EXPLAIN -> Group (no aggregates) (rows=27.7) (actual rows=40 loops=1) -> Sort: t1.e, t1.f (rows=40) (actual rows=40 loops=1) -> Filter: (t1.b > 95) (rows=40) (actual rows=40 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY c+0,e+0; EXPLAIN -> Group (no aggregates) (rows=100) (actual rows=55 loops=1) -> Sort: (t1.c + 0), (t1.e + 0) (rows=1000) (actual rows=1000 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 WHERE b>95 GROUP BY c+0,e+0; EXPLAIN -> Group (no aggregates) (rows=11.7) (actual rows=40 loops=1) -> Sort: (t1.c + 0), (t1.e + 0) (rows=40) (actual rows=40 loops=1) -> Filter: (t1.b > 95) (rows=40) (actual rows=40 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) EXPLAIN ANALYZE SELECT 1 FROM t1 GROUP BY a,e,c+0; EXPLAIN -> Group (no aggregates) (rows=501) (actual rows=595 loops=1) -> Sort: t1.a, t1.e, (t1.c + 0) (rows=1000) (actual rows=1000 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=1) CREATE TABLE t2 ( c1 INT, c2 INT, c3 INT, PRIMARY KEY(c1,c2) ); INSERT INTO t2 SELECT n%5,n/5,n%3 FROM num10; ANALYZE TABLE t2 UPDATE HISTOGRAM ON c3; Table Op Msg_type Msg_text test.t2 histogram status Histogram statistics created for column 'c3'. ANALYZE TABLE t2; Table Op Msg_type Msg_text test.t2 analyze status OK EXPLAIN ANALYZE SELECT 1 FROM t1,t2 GROUP BY c1; EXPLAIN -> Group (no aggregates) (rows=5) (actual rows=5 loops=1) -> Nested loop inner join (rows=10000) (actual rows=10000 loops=1) -> Covering index scan on t2 using PRIMARY (rows=10) (actual rows=10 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=10) EXPLAIN ANALYZE SELECT 1 FROM t1,t2 GROUP BY c2; EXPLAIN -> Group (no aggregates) (rows=3.16) (actual rows=3 loops=1) -> Nested loop inner join (rows=10000) (actual rows=10000 loops=1) -> Sort: t2.c2 (rows=10) (actual rows=10 loops=1) -> Table scan on t2 (rows=10) (actual rows=10 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=10) EXPLAIN ANALYZE SELECT 1 FROM t1,t2 GROUP BY c3; EXPLAIN -> Group (no aggregates) (rows=3) (actual rows=3 loops=1) -> Nested loop inner join (rows=10000) (actual rows=10000 loops=1) -> Sort: t2.c3 (rows=10) (actual rows=10 loops=1) -> Table scan on t2 (rows=10) (actual rows=10 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=10) EXPLAIN ANALYZE SELECT 1 FROM t1,t2 GROUP BY a,c3; EXPLAIN -> Group (no aggregates) (rows=23) (actual rows=33 loops=1) -> Sort: t1.a, t2.c3 (rows=10000) (actual rows=10000 loops=1) -> Nested loop inner join (rows=10000) (actual rows=10000 loops=1) -> Table scan on t2 (rows=10) (actual rows=10 loops=1) -> Table scan on t1 (rows=1000) (actual rows=1000 loops=10) DROP VIEW num1000; DROP TABLE num10, t1, t2;
Save File
Cancel