Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2(EOL)
Description
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0;
|
+-------------------+
|
| count(distinct s) |
|
+-------------------+
|
| 1000 |
|
+-------------------+
|
1 row in set (0.28 sec)
|
|
MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0;
|
+-------------------+
|
| count(distinct s) |
|
+-------------------+
|
| 2120 |
|
+-------------------+
|
1 row in set (0.29 sec)
|
1000 <> 2120
MariaDB [dw]>
|
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0;
|
+-------------------+
|
| count(distinct s) |
|
+-------------------+
|
| 630 |
|
+-------------------+
|
1 row in set (0.23 sec)
|
|
MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0;
|
+-------------------+
|
| count(distinct s) |
|
+-------------------+
|
| 976 |
|
+-------------------+
|
1 row in set (0.11 sec)
|
630 <> 976
MariaDB [dw]>
|
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0;
|
+-------------------+
|
| count(distinct s) |
|
+-------------------+
|
| 0 |
|
+-------------------+
|
1 row in set (0.15 sec)
|
|
MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0;
|
+-------------------+
|
| count(distinct s) |
|
+-------------------+
|
| 1 |
|
+-------------------+
|
1 row in set (0.08 sec)
|
0 <> 1
Test case :
drop table if exists t; |
create table t(a int,b int, c int , d int); |
insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); |
insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); |
replace into t(a,b,c,d) select 1, rand()*1000, rand()*1000, rand()*1000 from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14, t t15, t t16, t t17; |
|
select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; |
select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; |
|
select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; |
select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; |
|
select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; |
select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; |
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Assignee | Vicentiu Ciorbaru [ cvicentiu ] |
Component/s | Optimizer - Window functions [ 13502 ] | |
Component/s | OTHER [ 10125 ] |
Fix Version/s | 10.2 [ 14601 ] |
Description |
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0;
+-------------------+ | count(distinct s) | +-------------------+ | 1000 | +-------------------+ 1 row in set (0.28 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 2120 | +-------------------+ 1 row in set (0.29 sec) 1000 <> 2120 MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 630 | +-------------------+ 1 row in set (0.23 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 976 | +-------------------+ 1 row in set (0.11 sec) 630 <> 976 MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 0 | +-------------------+ 1 row in set (0.15 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.08 sec) 0 <> 1 Test case : drop table if exists t; create table t(a int,b int, c int , d int); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); replace into t(a,b,c,d) select 1, rand()*1000, rand()*1000, rand()*1000 from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14, t t15, t t16, t t17; select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; |
{noformat}
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1000 | +-------------------+ 1 row in set (0.28 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 2120 | +-------------------+ 1 row in set (0.29 sec) 1000 <> 2120 MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 630 | +-------------------+ 1 row in set (0.23 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 976 | +-------------------+ 1 row in set (0.11 sec) 630 <> 976 MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 0 | +-------------------+ 1 row in set (0.15 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.08 sec) {noformat} 0 <> 1 {noformat} Test case : {code:sql} drop table if exists t; create table t(a int,b int, c int , d int); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); replace into t(a,b,c,d) select 1, rand()*1000, rand()*1000, rand()*1000 from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14, t t15, t t16, t t17; select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; {code} |
Description |
{noformat}
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1000 | +-------------------+ 1 row in set (0.28 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 2120 | +-------------------+ 1 row in set (0.29 sec) 1000 <> 2120 MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 630 | +-------------------+ 1 row in set (0.23 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 976 | +-------------------+ 1 row in set (0.11 sec) 630 <> 976 MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 0 | +-------------------+ 1 row in set (0.15 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.08 sec) {noformat} 0 <> 1 {noformat} Test case : {code:sql} drop table if exists t; create table t(a int,b int, c int , d int); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); replace into t(a,b,c,d) select 1, rand()*1000, rand()*1000, rand()*1000 from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14, t t15, t t16, t t17; select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; {code} |
{noformat}
MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1000 | +-------------------+ 1 row in set (0.28 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 2120 | +-------------------+ 1 row in set (0.29 sec) {noformat} 1000 <> 2120 {noformat} MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 630 | +-------------------+ 1 row in set (0.23 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 976 | +-------------------+ 1 row in set (0.11 sec) {noformat} 630 <> 976 {noformat} MariaDB [dw]> MariaDB [dw]> select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 0 | +-------------------+ 1 row in set (0.15 sec) MariaDB [dw]> select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; +-------------------+ | count(distinct s) | +-------------------+ | 1 | +-------------------+ 1 row in set (0.08 sec) {noformat} 0 <> 1 Test case : {code:sql} drop table if exists t; create table t(a int,b int, c int , d int); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); insert into t(a,b,c,d) values(1, rand()*1000, rand()*1000, rand()*1000); replace into t(a,b,c,d) select 1, rand()*1000, rand()*1000, rand()*1000 from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14, t t15, t t16, t t17; select count(distinct s) from (select sum(d) over(partition by a,b,c) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b,c) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a,b) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a,b) Z where s > 0; select count(distinct s) from (select sum(d) over(partition by a) as s from t) Z where s > 0; select count(distinct s) from (select sum(d) as s from t group by a) Z where s > 0; {code} |
Issue Type | Task [ 3 ] | Bug [ 1 ] |
Affects Version/s | 10.2 [ 14601 ] |
Labels | 10.2-rc |
Status | Open [ 1 ] | In Progress [ 3 ] |
Fix Version/s | 10.2.4 [ 22116 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 76845 ] | MariaDB v4 [ 150838 ] |
This is due to our current limitation regarding SORT_BUFFER_SIZE.
As a temporary fix, setting SORT_BUFFER_SIZE to a large enough value such that all values fit in memory will generate the correct results.
set SORT_BUFFER_SIZE=1024*1024*1024
Ought to fix it.