summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/sum_distinct-big.result
blob: 086dd33fad21c0b3dc0f529b498f93b3139b3c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
set @save_tmp_table_size=@@tmp_table_size;
set @save_max_heap_table_size=@@max_heap_table_size;
set default_storage_engine=MYISAM;
CREATE TABLE t1 (id INTEGER);
CREATE TABLE t2 (id INTEGER);
INSERT INTO t1 SELECT b.seq FROM seq_1_to_128,seq_1_to_1024 b;
SELECT AVG(DISTINCT id) FROM t1 GROUP BY id % 13;
AVG(DISTINCT id)
513.5000
508.0000
509.0000
510.0000
511.0000
512.0000
513.0000
514.0000
515.0000
516.0000
517.0000
511.5000
512.5000
SELECT SUM(DISTINCT id)/COUNT(DISTINCT id) FROM t1 GROUP BY id % 13;
SUM(DISTINCT id)/COUNT(DISTINCT id)
513.5000
508.0000
509.0000
510.0000
511.0000
512.0000
513.0000
514.0000
515.0000
516.0000
517.0000
511.5000
512.5000
INSERT INTO t1 SELECT b.seq FROM seq_1_to_128,seq_1025_to_16384 b;
INSERT INTO t2 SELECT b.seq FROM seq_1_to_128 a,seq_1_to_16384 b
ORDER by (a.seq*0+b.seq)*rand();
SELECT SUM(DISTINCT id) sm FROM t1;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t2;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t1 group by id % 13;
sm
10327590
10328851
10330112
10331373
10332634
10317510
10318770
10320030
10321290
10322550
10323810
10325070
10326330
SET max_heap_table_size=16384;
SHOW variables LIKE 'max_heap_table_size';
Variable_name	Value
max_heap_table_size	16384
SELECT SUM(DISTINCT id) sm FROM t1;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t2;
sm
134225920
SELECT SUM(DISTINCT id) sm FROM t1 GROUP BY id % 13;
sm
10327590
10328851
10330112
10331373
10332634
10317510
10318770
10320030
10321290
10322550
10323810
10325070
10326330
# 
# Bug mdev-4063: SUM(DISTINCT...) with small'max_heap_table_size 
# (bug #56927)
# 
SET max_heap_table_size=default;
INSERT INTO t1 SELECT b.seq FROM seq_1_to_128,seq_16385_to_32768 b;
TRUNCATE t2;
INSERT INTO t2 SELECT b.seq FROM seq_1_to_128 a,seq_1_to_32768 b
ORDER BY (a.seq*0+b.seq)*rand();
SELECT SUM(DISTINCT id) sm FROM t2;
sm
536887296
SET max_heap_table_size=16384;
SELECT SUM(DISTINCT id) sm FROM t2;
sm
536887296
DROP TABLE t1;
DROP TABLE t2;
SET @@tmp_table_size=@save_tmp_table_size;
SET @@max_heap_table_size=@save_max_heap_table_size;
#
# MDEV-4311: COUNT(DISTINCT...) requiring a file for UNIQUE (bug #68749)
#
CREATE TABLE t2 (id INTEGER) ENGINE=InnoDB;
BEGIN;
INSERT INTO t2 SELECT b.seq FROM seq_1_to_128 a, seq_1_to_16384 b
ORDER BY b.seq*rand();
INSERT INTO t2 VALUE(NULL);
# With default tmp_table_size / max_heap_table_size
SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2;
sm
16384
set @@tmp_table_size=1024*256;
# With reduced tmp_table_size
SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2;
sm
16384
set @@tmp_table_size=@save_tmp_table_size;
SET @@max_heap_table_size=1024*256;
# With reduced max_heap_table_size
SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2;
sm
16384
SET @@max_heap_table_size=@save_max_heap_table_size;
# Back to default tmp_table_size / max_heap_table_size
SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2;
sm
16384
COMMIT;
DROP TABLE t2;