init push

This commit is contained in:
oceanbase-admin
2021-05-31 22:56:52 +08:00
commit cea7de1475
7020 changed files with 5689869 additions and 0 deletions

View File

@ -0,0 +1,7 @@
create database opt_est;
use opt_est;
create table t1(c1 int, c2 int, primary key(c1));
create table t2(c1 int, c2 int, primary key(c1));
create table t3(c1 varchar(20), c2 int, primary key(c1));
create table t4(c1 datetime, c2 timestamp, c3 date, c4 time, c5 year, primary key(c1));
create table t5(c1 decimal(20));

View File

@ -0,0 +1,458 @@
*************** Case 1 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1;
=====================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
-------------------------------------
|0 |HASH JOIN | |14250 |24667|
|1 | TABLE SCAN|t1 |10000 |3818 |
|2 | TABLE SCAN|t2 |2000 |785 |
=====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range(MIN ; MAX)always true
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(MIN ; MAX)always true
*************** Case 1(end) **************
*************** Case 2 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1;
====================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
------------------------------------
|0 |HASH JOIN | |2 |1496|
|1 | TABLE GET |t1 |1 |52 |
|2 | TABLE SCAN|t2 |2000 |785 |
====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range[1 ; 1],
range_cond([t1.c1 = 1])
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(MIN ; MAX)always true
*************** Case 2(end) **************
*************** Case 3 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 > 1;
====================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
------------------------------------
|0 |HASH JOIN | |144 |1688|
|1 | TABLE SCAN|t1 |100 |52 |
|2 | TABLE SCAN|t2 |2000 |785 |
====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range(1 ; MAX),
range_cond([t1.c1 > 1])
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(MIN ; MAX)always true
*************** Case 3(end) **************
*************** Case 4 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t2.c1 = 1;
=====================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
-------------------------------------
|0 |HASH JOIN | |10 |14832|
|1 | TABLE SCAN|t1 |10000 |3818 |
|2 | TABLE GET |t2 |1 |52 |
=====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range(MIN ; MAX)always true
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range[1 ; 1],
range_cond([t2.c1 = 1])
*************** Case 4(end) **************
*************** Case 5 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t2.c1 > 1;
=====================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
-------------------------------------
|0 |HASH JOIN | |927 |15408|
|1 | TABLE SCAN|t1 |10000 |3818 |
|2 | TABLE SCAN|t2 |100 |52 |
=====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range(MIN ; MAX)always true
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(1 ; MAX),
range_cond([t2.c1 > 1])
*************** Case 5(end) **************
*************** Case 6 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1 and t2.c1 = 1;
===================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
-----------------------------------
|0 |HASH JOIN | |1 |106 |
|1 | TABLE GET|t1 |1 |52 |
|2 | TABLE GET|t2 |1 |52 |
===================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range[1 ; 1],
range_cond([t1.c1 = 1])
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range[1 ; 1],
range_cond([t2.c1 = 1])
*************** Case 6(end) **************
*************** Case 7 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 > 1 and t2.c1 = 1;
====================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
------------------------------------
|0 |HASH JOIN | |1 |215 |
|1 | TABLE SCAN|t1 |100 |52 |
|2 | TABLE GET |t2 |1 |52 |
====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range(1 ; MAX),
range_cond([t1.c1 > 1])
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range[1 ; 1],
range_cond([t2.c1 = 1])
*************** Case 7(end) **************
*************** Case 8 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1 and t2.c1 > 1;
====================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
------------------------------------
|0 |HASH JOIN | |1 |139 |
|1 | TABLE GET |t1 |1 |52 |
|2 | TABLE SCAN|t2 |100 |52 |
====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range[1 ; 1],
range_cond([t1.c1 = 1])
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(1 ; MAX),
range_cond([t2.c1 > 1])
*************** Case 8(end) **************
*************** Case 9 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 > 1 and t2.c1 > 1;
====================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
------------------------------------
|0 |HASH JOIN | |96 |303 |
|1 | TABLE SCAN|t1 |100 |52 |
|2 | TABLE SCAN|t2 |100 |52 |
====================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1]), filter(nil),
equal_conds([t1.c1 = t2.c1]), other_conds(nil)
1 - output([t1.c1]), filter(nil),
access([t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.c1]), range(1 ; MAX),
range_cond([t1.c1 > 1])
2 - output([t2.c1]), filter(nil),
access([t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(1 ; MAX),
range_cond([t2.c1 > 1])
*************** Case 9(end) **************
*************** Case 10 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1;
=========================================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
---------------------------------------------------------
|0 |HASH JOIN | |949995250|762142938|
|1 | NESTED-LOOP JOIN CARTESIAN| |100000000|70773404 |
|2 | TABLE SCAN |a |10000 |3818 |
|3 | MATERIAL | |10000 |5655 |
|4 | TABLE SCAN |b |10000 |3818 |
|5 | TABLE SCAN |c |10000 |3818 |
=========================================================
Outputs & filters:
-------------------------------------
0 - output([c.c1]), filter(nil),
equal_conds([b.c1 = c.c1]), other_conds(nil)
1 - output([b.c1]), filter(nil),
conds(nil), nl_params_(nil)
2 - output([a.c1]), filter(nil),
access([a.c1]), partitions(p0),
is_index_back=false,
range_key([a.c1]), range(MIN ; MAX)always true
3 - output([b.c1]), filter(nil)
4 - output([b.c1]), filter(nil),
access([b.c1]), partitions(p0),
is_index_back=false,
range_key([b.c1]), range(MIN ; MAX)always true
5 - output([c.c1]), filter(nil),
access([c.c1]), partitions(p0),
is_index_back=false,
range_key([c.c1]), range(MIN ; MAX)always true
*************** Case 10(end) **************
*************** Case 11 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1 and c.c1 = 1;
=========================================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
---------------------------------------------------------
|0 |HASH JOIN | |100000 |198770318|
|1 | NESTED-LOOP JOIN CARTESIAN| |100000000|70773404 |
|2 | TABLE SCAN |a |10000 |3818 |
|3 | MATERIAL | |10000 |5655 |
|4 | TABLE SCAN |b |10000 |3818 |
|5 | TABLE GET |c |1 |52 |
=========================================================
Outputs & filters:
-------------------------------------
0 - output([c.c1]), filter(nil),
equal_conds([b.c1 = c.c1]), other_conds(nil)
1 - output([b.c1]), filter(nil),
conds(nil), nl_params_(nil)
2 - output([a.c1]), filter(nil),
access([a.c1]), partitions(p0),
is_index_back=false,
range_key([a.c1]), range(MIN ; MAX)always true
3 - output([b.c1]), filter(nil)
4 - output([b.c1]), filter(nil),
access([b.c1]), partitions(p0),
is_index_back=false,
range_key([b.c1]), range(MIN ; MAX)always true
5 - output([c.c1]), filter(nil),
access([c.c1]), partitions(p0),
is_index_back=false,
range_key([c.c1]), range[1 ; 1],
range_cond([c.c1 = 1])
*************** Case 11(end) **************
*************** Case 12 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1 and c.c1 > 1;
=========================================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
---------------------------------------------------------
|0 |HASH JOIN | |9561745 |204381939|
|1 | NESTED-LOOP JOIN CARTESIAN| |100000000|70773404 |
|2 | TABLE SCAN |a |10000 |3818 |
|3 | MATERIAL | |10000 |5655 |
|4 | TABLE SCAN |b |10000 |3818 |
|5 | TABLE SCAN |c |100 |52 |
=========================================================
Outputs & filters:
-------------------------------------
0 - output([c.c1]), filter(nil),
equal_conds([b.c1 = c.c1]), other_conds(nil)
1 - output([b.c1]), filter(nil),
conds(nil), nl_params_(nil)
2 - output([a.c1]), filter(nil),
access([a.c1]), partitions(p0),
is_index_back=false,
range_key([a.c1]), range(MIN ; MAX)always true
3 - output([b.c1]), filter(nil)
4 - output([b.c1]), filter(nil),
access([b.c1]), partitions(p0),
is_index_back=false,
range_key([b.c1]), range(MIN ; MAX)always true
5 - output([c.c1]), filter(nil),
access([c.c1]), partitions(p0),
is_index_back=false,
range_key([c.c1]), range(1 ; MAX),
range_cond([c.c1 > 1])
*************** Case 12(end) **************
*************** Case 13 ***************
min = 1001, max = 10000, ndv = 1000, null_num = 500
t1 row count = 10000, t2 row count = 2000
t1 not null frac is (10000-500)/10000 = 0.95
t2 not null frac is (2000-500)/2000 = 0.75
SQL: select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1 and a.c1 = 1 and b.c1 = 1 and c.c1 = 1;
====================================================
|ID|OPERATOR |NAME|EST. ROWS|COST|
----------------------------------------------------
|0 |HASH JOIN | |1 |159 |
|1 | NESTED-LOOP JOIN CARTESIAN| |1 |105 |
|2 | TABLE GET |a |1 |52 |
|3 | TABLE GET |b |1 |52 |
|4 | TABLE GET |c |1 |52 |
====================================================
Outputs & filters:
-------------------------------------
0 - output([c.c1]), filter(nil),
equal_conds([b.c1 = c.c1]), other_conds(nil)
1 - output([b.c1]), filter(nil),
conds(nil), nl_params_(nil)
2 - output([a.c1]), filter(nil),
access([a.c1]), partitions(p0),
is_index_back=false,
range_key([a.c1]), range[1 ; 1],
range_cond([a.c1 = 1])
3 - output([b.c1]), filter(nil),
access([b.c1]), partitions(p0),
is_index_back=false,
range_key([b.c1]), range[1 ; 1],
range_cond([b.c1 = 1])
4 - output([c.c1]), filter(nil),
access([c.c1]), partitions(p0),
is_index_back=false,
range_key([c.c1]), range[1 ; 1],
range_cond([c.c1 = 1])
*************** Case 13(end) **************

View File

@ -0,0 +1,14 @@
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 > 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t2.c1 = 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t2.c1 > 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1 and t2.c1 = 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 > 1 and t2.c1 = 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 = 1 and t2.c1 > 1;
select /*+ LEADING(t1, t2) USE_HASH(t1, t2) */ t1.c1 from t1, t2 where t1.c1 = t2.c1 and t1.c1 > 1 and t2.c1 > 1;
# multi join
select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1;
select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1 and c.c1 = 1;
select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1 and c.c1 > 1;
select /*+ LEADING(a, b, c) USE_HASH(a, b, c) */ c.c1 from t1 a, t1 b, t1 c where b.c1 = c.c1 and a.c1 = 1 and b.c1 = 1 and c.c1 = 1;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,268 @@
#select c1 from t1 where c1 between 10000 and 1000;
#select c1 from t1 where c1 not in (500, 1000)
#select c1 from t1 where (c1, c2) = (2000, 10000);
#select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
#select c1 from t1 where c1 = 1000;
select 1.
select c1 from t1 where c1 > 1000 or c1 > 2000 and c1 < 3000;
# const
select 1;
select c1 from t1 where 1;
select 1;
select c1 from t1 where 1 > 0;
select 0;
select c1 from t1 where 0;
select 0;
select c1 from t1 where null;
# distinct(1000), min(500), max(10000), nullnum(100)
#equal a = 1
select 1/1000*0.95;
select c1 from t1 where c1 = 999;
select 1/1000*0.95;
select c1 from t1 where c1 = 10001;
select 1/1000*0.95;
select c1 from t1 where c1 = 1000;
select 500/10000
select c1 from t1 where c1 <=> null;
select 0
select c1 from t1 where c1 = null;
select 1/1000 * 0.95
select c1 from t1 where c1 + 1 = 1000;
select 1/1000 * 0.95
select c1 from t1 where c1 * 2 = 1000;
select 0.005(DEFAULT_EQ_SEL)
select c1 from t1 where c1 / 2 = 1000;
select 1/1000 * 0.95
select c1 from t1 where c1 - 100 = 1000;
# range cond
select 0;
select c1 from t1 where c1 > null;
select 1;
select c1 from t1 where c1 > null or 1 > 0;
select 0;
select c1 from t1 where c1 > null or 1 > 2;
select 0;
select c1 from t1 where c1 < null;
select 0.95;
select c1 from t1 where c1 > 30;
select 2*1/1000 * 0.95;
select c1 from t1 where c1 < 50;
select 1.0/3.0 as not calc
select c1 from t1 where c1 + 1 > 5;
select (10000-2000)/(10000-1000) * 0.95;
select c1 from t1 where c1 > 2000;
select 0.95;
select c1 from t1 where c1 > 1000 or c1 > 2000 and c1 < 3000;
select (10000-2000)/(10000-1000) * 0.95 + 1/1000 * 0.95;
select c1 from t1 where c1 >= 2000;
select (5000-1000)/(10000-1000) * 0.95;
select c1 from t1 where c1 < 5000;
select (5000-1000)/(10000-1000) * 0.95 + 1/1000 * 0.95;
select c1 from t1 where c1 <= 5000;
select 20*1/1000 * 0.95(min_distinct 20);
select c1 from t1 where c1 <= 500;
select 20*1/1000 * 0.95;
select c1 from t1 where c1 >= 10000;
select 1 - 1/1000*0.95 - 100/10000
select c1 from t1 where c1 != 500;
select 1 - 1/1000*0.95 - 100/10000
select c1 from t1 where c1 != 50;
select 1 - 1/1000*0.95 - 100/10000
select c1 from t1 where c1 != 50;
select 1 - 1/1000*0.95 - 100/10000
select c1 from t1 where c1 + 1 != 50;
select 1 - 1/1000*0.95 - 100/10000
select c1 from t1 where c1 * 2 != 50;
select 0.5
select c1 from t1 where c1 / 2 != 50;
select (10000-2000)/(10000-1000)*0.95;
select c1 from t1 where c1 > 2000;
select (3000-1000)/(10000-1000)*0.95;
select c1 from t1 where c1 < 3000;
select 2*1/1000 * 0.95;
select c1 from t1 where c1 > 10000;
select 0.95;
select c1 from t1 where c1 > 500;
select 2*1/1000 * 0.95;
select c1 from t1 where c1 < 500;
select 2*1/1000 * 0.95;
select c1 from t1 where c1 < 1000;
select (10000-9000)/(10000-1000)*0.95;
select c1 from t1 where c1 > 9000;
select (8000-1000)/(10000-1000)*0.95;
select c1 from t1 where c1 < 8000;
select (3000-2000)/(10000-1000)*0.95;
select c1 from t1 where c1 > 2000 and c1 < 3000;
select 0.019;
select c1 from t1 where c1 > 10000 and c1 > 500;
select 0.95;
select c1 from t1 where c1 < 10000 and c1 > 500;
select 0.019*2;
select c1 from t1 where c1 < 500 or c1 > 10000;
select (10000-2000)/(10000-1000)*0.95 + 0.019;
select c1 from t1 where c1 > 2000 or c1 < 1000;
select (10000-2000)/(10000-1000)*0.95 + 0.019;
select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
select (10000-2000)/(10000-1000)*0.95 + 0.0095;
select c1 from t1 where c1 > 2000 or c1 < 1000 and c1 > 500;
select 0.0095;
select c1 from t1 where c1 < 1000 and c1 > 500;
select 0.019;
select c1 from t1 where c1 < 1000 or c1 > 9000 and c1 > 2000 and c1 < 8000;
select 0.019;
select c1 from t1 where c1 < 500 or c1 > 10000 and c1 > 10001 and c1 < 499;
#T_OP_IS
select 500/10000;
select c1 from t1 where c1 is null;
select 1/1000 * 0.95;
select c1 from t1 where c1 is false;
select 1 * 0.95 - 1/1000(suppose the ratio of false);
select c1 from t1 where c1 is true;
#T_OP_NOT
select 1 - 500/10000;
select c1 from t1 where c1 is not null;
select 1 - 1/1000 * 0.95;
select c1 from t1 where c1 is not false;
select 1 - 0.95;
select c1 from t1 where c1 is not true;
select 0;
select * from t1 where not 1;
select 1;
select * from t1 where not 0;
select 0.95 - (10000-2000)/(10000-1000)*0.95;
select * from t1 where not c1 > 2000;
select 0.95 - (3000-2000)/(10000-1000)*0.95;
select * from t1 where not (c1 > 2000 and c1 < 3000);
select 0.95 - 1/1000*0.95*3;
select * from t1 where not c1 in (2000, 3000);
#T_OP_IN
#T_OP_NOT_IN.
select 1/1000*0.95 * 3;
select c1 from t1 where c1 in (500, 8000, 10000);
select square(1/1000*0.95) * 2
select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
select 0.95 - 0.95*2;
select c1 from t1 where c1 not in (500, 1000);
# const in const
select 1;
select c1 from t1 where (200) in (100, 200);
select 1;
select c1 from t1 where (200) in (100, 300, 400, 200);
select 0;
select c1 from t1 where (200) in (100, 300, 400, 500);
select 1/1000*0.95;
select c1 from t1 where (200) in (c1, 300, 400, 500);
select 0.95;
select c1 from t1 where (c1) in (c1, 300, 400, 500);
select 1;
select c1 from t1 where 200 in ('200', c2, 300, 400, 500);
select 1;
select c1 from t3 where 'a' in ('A', c1, '300', '400', '500');
select 1/80*(10000 - 10) | str(distinct 80, null:10);
select c1 from t3 where c1 = 'a';
select 1/80*(10000 - 10) | str(distinct 80, null:10);
select c1 from t3 where 'a' in ('A' collate 'utf8mb4_bin', c1, '300', '400', '500');
select 1/1000*0.95 * 3;
select c1 from t1 where c1 in (500, 8000, 10000);
EXPECTED select 0.95 - 1/1000*0.95 * 3;
select c1 from t1 where c1 not in (500, 8000, 10000);
EXPECTED select 1/1000*0.95 * 2;
select c1 from t1 where c1 in (500, 1000);
EXPECTED select 0.95 - 1/1000*0.95 * 2;
select c1 from t1 where c1 not in (500, 1000);
EXPECTED select 1/1000*0.95 * 1/1000*0.95*2;
select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
EXPECTED select 0.95 - 1/1000*0.95 * 1/1000*0.95*2;
select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
#BTW, NOT BTW
select 0.95;
select c1 from t1 where c1 between 1000 and 10000;
select 20/1000*.95 + 20/1000*0.95,20:minest of half open range
select c1 from t1 where c1 not between 1000 and 10000;
select 1/1000*0.95;
select c1 from t1 where c1 between 1000 and 1000;
select 0.95;
select c1 from t1 where c1 not between 1000 and 1000;
select 0;#bug 8551829 :6;
select c1 from t1 where c1 between 10000 and 1000;
select 1;
select c1 from t1 where c1 not between 10000 and 1000;
select 0.018*0.018;
select c1 from t1 where c1 >= 10000 and c1<=1000;
select 1/1000*0.95;
select c1 from t1 where 1000 between c1 and 1000;
select 1 - 1/1000*0.95;
select c1 from t1 where 1000 not between c1 and 1000;
select (2000-1000)/(10000-1000)*0.95;
select c1 from t1 where 2000 between c1 and 10000;
select (10000-8000)/(10000-1000)*0.95;
select c1 from t1 where 2000 not between c1 and 10000;
select 0;
select c1 from t1 where 1000 between 10000 and c1;
select (10000-2000)/(10000-1000)*0.95;
select c1 from t1 where 2000 between 1000 and c1;
select 1;
select c1 from t1 where 1 between 0 and 1;
select 0;
select c1 from t1 where 100 between 0 and 1;
#JOIN COND
# min(basic_sel1, basic_sel2)
select 1/1000*((2000 - 500)/2000) table2: row count = 2000;
select t1.c1 from t1,t2 where t1.c1 = t2.c1;
select 1/1000*0.75 table2: row count = 2000;
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
select 1/1000*0.75 table2: row count = 2000;
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
select 1/1000*0.75 table2: row count = 2000;
select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
select 1/1000*0.75 table2: row count = 2000;
select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
select 1/1000*0.75 * 1/3;
select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
select 1/3;
select t1.c1 from t1, t2 where t1.c1 < t2.c2;
select 0.5;
select t1.c1 from t1, t2 where t1.c1 != t2.c2;
# IS_WITH_SUBQUERY
select 1/1000*0.95
select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
select 1.0 / 3.0 DEFAULT_INEQ_SEL
select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
todo. 1 - 1/1000*0.95 - 0.05
select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
#ROW
select 1/1000 * 0.95 * (1/1000 * 0.95)
select c1 from t1 where (c1, c2) = (2000, 10000);
todo. T_OP_ROW != T_OP_ROW
select c1 from t1 where (c1, c2) != (2000, 10000);
select (10000 - 2000)/(10000 - 1001) * 0.95
select c1 from t1 where (c1, c2) > (2000, 10000);
# test decimal
AC: not null = 0.95
select c1 from t5 where c1 < 10001;
AC: not null = 0.95
select c1 from t5 where c1 > 1000;
AC: not null = 0.95
select c1 from t5 where c1 <= 10000;
AC: not null = 0.95
select c1 from t5 where c1 >= 1001;
AC: not null / 2 near 0.47
select c1 from t5 where c1 > 5500;
AC: not null / 2 near 0.47
select c1 from t5 where c1 < 5500;

View File

@ -0,0 +1,84 @@
EXPR_STR: select c1 from t4 where c1 > '20150305123012';
SELECTIVITY = 0.808483
EXPR_STR: select c1 from t4 where c1 = '20150305123012';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c1 > '00000101000000';
SELECTIVITY = 1
EXPR_STR: select c1 from t4 where c1 < '00000101000000';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t4 where c1 > '99991231235959';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c1 < '99991231235959';
SELECTIVITY = 1
EXPR_STR: select c1 from t4 where c2 > '20150305123012';
SELECTIVITY = 0.516212
EXPR_STR: select c1 from t4 where c2 = '20150305123012';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c2 > '00000102080000';
SELECTIVITY = 0.633968
EXPR_STR: select c1 from t4 where c2 < '00000102080000';
SELECTIVITY = 0.0100002
EXPR_STR: select c1 from t4 where c2 > '99991230235959';
SELECTIVITY = 0.0100002
EXPR_STR: select c1 from t4 where c2 < '99991230235959';
SELECTIVITY = 0.633968
EXPR_STR: select c1 from t4 where c3 > '2012-01-01';
SELECTIVITY = 0.572686
EXPR_STR: select c1 from t4 where c3 = '2016-07-27';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c3 > '1000-01-01';
SELECTIVITY = 0.633968
EXPR_STR: select c1 from t4 where c3 < '1000-01-01';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c3 > '9999-12-31';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t4 where c3 < '9999-12-31';
SELECTIVITY = 0.633968
EXPR_STR: select c1 from t4 where c4 = '12:01:01';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c4 < '838:59:59';
SELECTIVITY = 0.633968
EXPR_STR: select c1 from t4 where c4 > '838:59:59';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t4 where c4 > '00:00:00';
SELECTIVITY = 0.633968
EXPR_STR: select c1 from t4 where c4 < '00:00:00';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t4 where c5 = 2016;
SELECTIVITY = 0.01
EXPR_STR: select c1 from t4 where c5 > 1970;
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t4 where c5 < 1970;
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t4 where c5 > 2155;
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t4 where c5 < 2155;
SELECTIVITY = 0.333333

View File

@ -0,0 +1,28 @@
select c1 from t4 where c1 > '20150305123012';
select c1 from t4 where c1 = '20150305123012';
select c1 from t4 where c1 > '00000101000000';
select c1 from t4 where c1 < '00000101000000';
select c1 from t4 where c1 > '99991231235959';
select c1 from t4 where c1 < '99991231235959';
select c1 from t4 where c2 > '20150305123012';
select c1 from t4 where c2 = '20150305123012';
select c1 from t4 where c2 > '00000102080000';
select c1 from t4 where c2 < '00000102080000';
select c1 from t4 where c2 > '99991230235959';
select c1 from t4 where c2 < '99991230235959';
select c1 from t4 where c3 > '2012-01-01';
select c1 from t4 where c3 = '2016-07-27';
select c1 from t4 where c3 > '1000-01-01';
select c1 from t4 where c3 < '1000-01-01';
select c1 from t4 where c3 > '9999-12-31';
select c1 from t4 where c3 < '9999-12-31';
select c1 from t4 where c4 = '12:01:01';
select c1 from t4 where c4 < '838:59:59';
select c1 from t4 where c4 > '838:59:59';
select c1 from t4 where c4 > '00:00:00';
select c1 from t4 where c4 < '00:00:00';
select c1 from t4 where c5 = 2016;
select c1 from t4 where c5 > 1970;
select c1 from t4 where c5 < 1970;
select c1 from t4 where c5 > 2155;
select c1 from t4 where c5 < 2155;

View File

@ -0,0 +1,776 @@
******************CASE0******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 1000 or (c1 > 2000 and c1 < 3000);
SELECTIVITY = 0.1
******************CASE1******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1;
SELECTIVITY = 1
******************CASE2******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1 > 0;
SELECTIVITY = 1
******************CASE3******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 0;
SELECTIVITY = 0
******************CASE4******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where null;
SELECTIVITY = 0
******************CASE5******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 999;
SELECTIVITY = 0.01
******************CASE6******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 10001;
SELECTIVITY = 0.01
******************CASE7******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1000;
SELECTIVITY = 0.01
******************CASE8******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.01
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <=> null;
SELECTIVITY = 0
******************CASE9******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = null;
SELECTIVITY = 0
******************CASE10******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 = 1000;
SELECTIVITY = 0.01
******************CASE11******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 * 2 = 1000;
SELECTIVITY = 0.01
******************CASE12******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.005(DEFAULT_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 / 2 = 1000;
SELECTIVITY = 0.005
******************CASE13******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 - 100 = 1000;
SELECTIVITY = 0.01
******************CASE14******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null;
SELECTIVITY = 0
******************CASE15******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null or 1 > 0;
SELECTIVITY = 1
******************CASE16******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null or 1 > 2;
SELECTIVITY = 0
******************CASE17******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < null;
SELECTIVITY = 0
******************CASE18******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 30;
SELECTIVITY = 0.1
******************CASE19******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 50;
SELECTIVITY = 0.1
******************CASE20******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1.0/3.0 as not calc
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 > 5;
SELECTIVITY = 0.333333
******************CASE21******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000;
SELECTIVITY = 0.1
******************CASE22******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 2000;
SELECTIVITY = 0.1
******************CASE23******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 5000;
SELECTIVITY = 0.1
******************CASE24******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select (5000-1000)/(10000-1000) * 0.95;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 5000;
SELECTIVITY = 0.1
******************CASE25******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 500;
SELECTIVITY = 0.1
******************CASE26******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 10000;
SELECTIVITY = 0.1
******************CASE27******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1 - 0.01 - 1/500*0.99
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != 500;
SELECTIVITY = 0.99
******************CASE28******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1 - 0.01 - 1/500*0.99
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != 50;
SELECTIVITY = 0.99
******************CASE29******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1 - 0.01 - 1/500*0.99
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 != 50;
SELECTIVITY = 0.99
******************CASE30******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1 - 0.01 - 1/500*0.99
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 * 2 != 50;
SELECTIVITY = 0.99
******************CASE31******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 / 2 != 50;
SELECTIVITY = 0.5
******************CASE32******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 5 * 1 / 500 * 0.99 (5 * EST_DEF_VAR_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 and c1 < 3000;
SELECTIVITY = 0.05
******************CASE33******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 10000 and c1 > 500;
SELECTIVITY = 0.1
******************CASE34******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 5 * 1 / 500 * 0.99 (5 * EST_DEF_VAR_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 10000 and c1 > 500;
SELECTIVITY = 0.05
******************CASE35******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 * 2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 500 or c1 > 10000;
SELECTIVITY = 0.2
******************CASE36******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 * 2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or c1 < 1000;
SELECTIVITY = 0.2
******************CASE37******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 * 2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
SELECTIVITY = 0.2
******************CASE38******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 + 0.0099
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or (c1 < 1000 and c1 > 500);
SELECTIVITY = 0.15
******************CASE39******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 5 * 1 / 500 * 0.99 (5 * EST_DEF_VAR_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1000 and c1 > 500;
SELECTIVITY = 0.05
******************CASE40******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1000 or (c1 > 9000 and c1 > 2000 and c1 < 8000);
SELECTIVITY = 0.1
******************CASE41******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 500 or (c1 > 10000 and c1 > 10001 and c1 < 499);
SELECTIVITY = 0.1
******************CASE42******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.01
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is null;
SELECTIVITY = 0
******************CASE43******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500 * 0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is false;
SELECTIVITY = 0.01
******************CASE44******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1- 0.01 - 1/500*0.99(suppose the ratio of false);
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is true;
SELECTIVITY = 0.99
******************CASE45******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1 - 0.01;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not null;
SELECTIVITY = 1
******************CASE46******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1 - 1/500 * 0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not false;
SELECTIVITY = 0.99
******************CASE47******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.01 + 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not true;
SELECTIVITY = 0.01
******************CASE48******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select * from t1 where not 1;
SELECTIVITY = 0
******************CASE49******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select * from t1 where not 0;
SELECTIVITY = 1
******************CASE50******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2;
----------------------------------------------------------
EXPR_STR: select * from t1 where not c1 > 2000;
SELECTIVITY = 0.1
******************CASE51******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2 + 0.2;
----------------------------------------------------------
EXPR_STR: select * from t1 where not (c1 > 2000 and c1 < 3000);
SELECTIVITY = 0.2
******************CASE52******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.99 - 1/500*0.99*2;
----------------------------------------------------------
EXPR_STR: select * from t1 where not c1 in (2000, 3000);
SELECTIVITY = 0.98
******************CASE53******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99 * 3;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 in (500, 8000, 10000);
SELECTIVITY = 0.03
******************CASE54******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select square(1/500*0.99) * 2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
SELECTIVITY = 0.0002
******************CASE55******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 200);
SELECTIVITY = 1
******************CASE56******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 300, 400, 200);
SELECTIVITY = 1
******************CASE57******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 300, 400, 500);
SELECTIVITY = 0
******************CASE58******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (c1, 300, 400, 500);
SELECTIVITY = 0.01
******************CASE59******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1) in (c1, 300, 400, 500);
SELECTIVITY = 1
******************CASE60******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :EXPECTED select 0.99 - 1/500*0.99 * 3;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not in (500, 8000, 10000);
SELECTIVITY = 0.97
******************CASE61******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :EXPECTED select 0.99 - 1/500*0.99 * 2;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not in (500, 1000);
SELECTIVITY = 0.98
******************CASE62******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :EXPECTED select 0.99 - 1/500*0.99 * 1/500*0.99*2;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
SELECTIVITY = 0.9998
******************CASE63******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99*5;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 1000 and 10000;
SELECTIVITY = 0.05
******************CASE64******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.4;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 1000 and 10000;
SELECTIVITY = 0.2
******************CASE65******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 1000 and 1000;
SELECTIVITY = 0.0099
******************CASE66******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.4;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 1000 and 1000;
SELECTIVITY = 0.2
******************CASE67******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 10000 and 1000;
SELECTIVITY = 0
******************CASE68******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.4;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 10000 and 1000;
SELECTIVITY = 0.1
******************CASE69******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 10000 and c1<=1000;
SELECTIVITY = 0
******************CASE70******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 between c1 and 1000;
SELECTIVITY = 0.1
******************CASE71******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 not between c1 and 1000;
SELECTIVITY = 0.333333
******************CASE72******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 between 10000 and c1;
SELECTIVITY = 0.1
******************CASE73******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 2000 between 1000 and c1;
SELECTIVITY = 0.1
******************CASE74******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1 between 0 and 1;
SELECTIVITY = 1
******************CASE75******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 100 between 0 and 1;
SELECTIVITY = 0
******************CASE76******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 = t2.c1;
SELECTIVITY = 0.01
******************CASE77******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
SELECTIVITY = 0.01
******************CASE78******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
SELECTIVITY = 0.01
******************CASE79******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
SELECTIVITY = 0.01
******************CASE80******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
SELECTIVITY = 0.005
******************CASE81******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99 * (1/3);
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
SELECTIVITY = 0.00333333
******************CASE82******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/3;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1, t2 where t1.c1 < t2.c2;
SELECTIVITY = 0.333333
******************CASE83******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.5;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1, t2 where t1.c1 != t2.c2;
SELECTIVITY = 0.5
******************CASE84******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500*0.99
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.01
******************CASE85******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1.0 / 3.0 DEFAULT_INEQ_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.333333
******************CASE86******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. 1- 1/500*0.99 - 0.01
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.99
******************CASE87******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
SELECTIVITY = 0.5
******************CASE88******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE89******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE90******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE91******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE92******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE93******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE94******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 1/500 * 0.99 * (1/500 * 0.99)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) = (2000, 10000);
SELECTIVITY = 0.0001
******************CASE95******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :todo. 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) != (2000, 10000);
SELECTIVITY = 0.5
******************CASE96******************
min = MIN, max = MAX, ndv = 500, null_num = 10
the ratio of not null row is (1000-10)/1000 = 0.99
EXPECTED RESULT :select 0.2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) > (2000, 10000);
SELECTIVITY = 0.1

View File

@ -0,0 +1,212 @@
#select c1 from t1 where c1 between 10000 and 1000;
#select c1 from t1 where c1 not in (500, 1000)
#select c1 from t1 where (c1, c2) = (2000, 10000);
#select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
#select c1 from t1 where c1 = 1000;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 > 1000 or (c1 > 2000 and c1 < 3000);
# const
select 1;
select c1 from t1 where 1;
select 1;
select c1 from t1 where 1 > 0;
select 0;
select c1 from t1 where 0;
select 0;
select c1 from t1 where null;
# distinct(1000), min(500), max(10000), nullnum(100)
#equal a = 1
select 1/500*0.99;
select c1 from t1 where c1 = 999;
select 1/500*0.99;
select c1 from t1 where c1 = 10001;
select 1/500*0.99;
select c1 from t1 where c1 = 1000;
select 0.01
select c1 from t1 where c1 <=> null;
select 0
select c1 from t1 where c1 = null;
select 1/500*0.99;
select c1 from t1 where c1 + 1 = 1000;
select 1/500*0.99;
select c1 from t1 where c1 * 2 = 1000;
select 0.005(DEFAULT_EQ_SEL)
select c1 from t1 where c1 / 2 = 1000;
select 1/500*0.99;
select c1 from t1 where c1 - 100 = 1000;
# range cond
select 0;
select c1 from t1 where c1 > null;
select 1;
select c1 from t1 where c1 > null or 1 > 0;
select 0;
select c1 from t1 where c1 > null or 1 > 2;
select 0;
select c1 from t1 where c1 < null;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 > 30;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 < 50;
select 1.0/3.0 as not calc
select c1 from t1 where c1 + 1 > 5;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 > 2000;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 >= 2000;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 < 5000;
select (5000-1000)/(10000-1000) * 0.95;
select c1 from t1 where c1 <= 5000;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 <= 500;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 >= 10000;
select 1 - 0.01 - 1/500*0.99
select c1 from t1 where c1 != 500;
select 1 - 0.01 - 1/500*0.99
select c1 from t1 where c1 != 50;
select 1 - 0.01 - 1/500*0.99
select c1 from t1 where c1 + 1 != 50;
select 1 - 0.01 - 1/500*0.99
select c1 from t1 where c1 * 2 != 50;
select 0.5
select c1 from t1 where c1 / 2 != 50;
select 5 * 1 / 500 * 0.99 (5 * EST_DEF_VAR_EQ_SEL)
select c1 from t1 where c1 > 2000 and c1 < 3000;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 > 10000 and c1 > 500;
select 5 * 1 / 500 * 0.99 (5 * EST_DEF_VAR_EQ_SEL)
select c1 from t1 where c1 < 10000 and c1 > 500;
select 0.2 * 2
select c1 from t1 where c1 < 500 or c1 > 10000;
select 0.2 * 2
select c1 from t1 where c1 > 2000 or c1 < 1000;
select 0.2 * 2
select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
select 0.2 + 0.0099
select c1 from t1 where c1 > 2000 or (c1 < 1000 and c1 > 500);
select 5 * 1 / 500 * 0.99 (5 * EST_DEF_VAR_EQ_SEL)
select c1 from t1 where c1 < 1000 and c1 > 500;
select 0.2
select c1 from t1 where c1 < 1000 or (c1 > 9000 and c1 > 2000 and c1 < 8000);
select 0.2
select c1 from t1 where c1 < 500 or (c1 > 10000 and c1 > 10001 and c1 < 499);
#T_OP_IS
select 0.01
select c1 from t1 where c1 is null;
select 1/500 * 0.99;
select c1 from t1 where c1 is false;
select 1- 0.01 - 1/500*0.99(suppose the ratio of false);
select c1 from t1 where c1 is true;
#T_OP_NOT
select 1 - 0.01;
select c1 from t1 where c1 is not null;
select 1 - 1/500 * 0.99;
select c1 from t1 where c1 is not false;
select 0.01 + 1/500*0.99;
select c1 from t1 where c1 is not true;
select 0;
select * from t1 where not 1;
select 1;
select * from t1 where not 0;
select 0.2;
select * from t1 where not c1 > 2000;
select 0.2 + 0.2;
select * from t1 where not (c1 > 2000 and c1 < 3000);
select 0.99 - 1/500*0.99*2;
select * from t1 where not c1 in (2000, 3000);
#T_OP_IN
select 1/500*0.99 * 3;
select c1 from t1 where c1 in (500, 8000, 10000);
select square(1/500*0.99) * 2
select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
# const in const
select 1;
select c1 from t1 where (200) in (100, 200);
select 1;
select c1 from t1 where (200) in (100, 300, 400, 200);
select 0;
select c1 from t1 where (200) in (100, 300, 400, 500);
select 1;
select c1 from t1 where (200) in (c1, 300, 400, 500);
select 1;
select c1 from t1 where (c1) in (c1, 300, 400, 500);
EXPECTED select 0.99 - 1/500*0.99 * 3;
select c1 from t1 where c1 not in (500, 8000, 10000);
EXPECTED select 0.99 - 1/500*0.99 * 2;
select c1 from t1 where c1 not in (500, 1000);
EXPECTED select 0.99 - 1/500*0.99 * 1/500*0.99*2;
select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
#BTW, NOT BTW
select 1/500*0.99*5;
select c1 from t1 where c1 between 1000 and 10000;
select 0.4;
select c1 from t1 where c1 not between 1000 and 10000;
select 1/500*0.99;
select c1 from t1 where c1 between 1000 and 1000;
select 0.4;
select c1 from t1 where c1 not between 1000 and 1000;
select 0;
select c1 from t1 where c1 between 10000 and 1000;
select 0.4;
select c1 from t1 where c1 not between 10000 and 1000;
select 0;
select c1 from t1 where c1 >= 10000 and c1<=1000;
select 0.2;
select c1 from t1 where 1000 between c1 and 1000;
select 0.2;
select c1 from t1 where 1000 not between c1 and 1000;
select 0;
select c1 from t1 where 1000 between 10000 and c1;
select 0.2;
select c1 from t1 where 2000 between 1000 and c1;
select 1;
select c1 from t1 where 1 between 0 and 1;
select 0;
select c1 from t1 where 100 between 0 and 1;
#JOIN COND
# min(basic_sel1, basic_sel2)
select 1/500*0.99;
select t1.c1 from t1,t2 where t1.c1 = t2.c1;
select 1/500*0.99;
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
select 1/500*0.99;
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
select 1/500*0.99;
select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
select 1/500*0.99;
select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
select 1/500*0.99 * (1/3);
select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
select 1/3;
select t1.c1 from t1, t2 where t1.c1 < t2.c2;
select 0.5;
select t1.c1 from t1, t2 where t1.c1 != t2.c2;
# IS_WITH_SUBQUERY
select 1/500*0.99
select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
select 1.0 / 3.0 DEFAULT_INEQ_SEL
select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
todo. 1- 1/500*0.99 - 0.01
select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
#ROW
select 1/500 * 0.99 * (1/500 * 0.99)
select c1 from t1 where (c1, c2) = (2000, 10000);
todo. 0.5
select c1 from t1 where (c1, c2) != (2000, 10000);
select 0.2
select c1 from t1 where (c1, c2) > (2000, 10000);

View File

@ -0,0 +1,117 @@
******************CASE0******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :density * num_null = 0.002
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 10;
SELECTIVITY = 0.01
******************CASE1******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :density * num_null = 0.002
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 5.5;
SELECTIVITY = 0.01
******************CASE2******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :density * num_null = 0.002
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 20;
SELECTIVITY = 0.02
******************CASE3******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :density * num_null = 0.002
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1;
SELECTIVITY = 0.02
******************CASE4******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :5/200 * 0.8 = 0.02
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1;
SELECTIVITY = 0.01
******************CASE5******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :(5/200 + 0.0025) * 0.8 = 0.022
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 1;
SELECTIVITY = 0.02
******************CASE6******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :(103 - 5) / 200 * 0.8 = 0.392
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 2 and c1 <= 10;
SELECTIVITY = 0.431053
******************CASE7******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :((103 - 5) / 200) * 0.8 = 0.392
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 1.5 and c1 <= 10;
SELECTIVITY = 0.431053
******************CASE8******************
min = 1, max = 20, ndv = 20, null_num = 50
num_row = 250, density = 0.0025, bucket count = 200
the ratio of not null row is (250-50)/250 = 0.8
| val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
| acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
EXPECTED RESULT :((103 - 5) / 200 + 0.0025) * 0.8 = 0.393
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 2 and c1 < 10.5;
SELECTIVITY = 0.473684

View File

@ -0,0 +1,28 @@
# ***Case Data***
# min = 1, max = 20, ndv = 20, null_num = 50
# num_row = 250, density = 0.0025, bucket count = 200
# the ratio of not null row is (250-50)/250 = 0.8
# | val | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
# | cnt | 5 | 14 | 13 | 16 | 9 | 7 | 10 | 13 | 15 | 1 | 5 | 6 | 10 | 9 | 9 | 12 | 21 | 11 | 11 | 3 |
# | acc | 5 | 19 | 32 | 48 | 57 | 64 | 74 | 87 | 102 | 103 | 108 | 114 | 124 | 133 | 142 | 154 | 175 | 186 | 197 | 200 |
density * num_null = 0.002
select c1 from t1 where c1 = 10;
density * num_null = 0.002
select c1 from t1 where c1 = 5.5;
density * num_null = 0.002
select c1 from t1 where c1 > 20;
density * num_null = 0.002
select c1 from t1 where c1 < 1;
5/200 * 0.8 = 0.02
select c1 from t1 where c1 = 1;
(5/200 + 0.0025) * 0.8 = 0.022
select c1 from t1 where c1 <= 1;
(103 - 5) / 200 * 0.8 = 0.392
select c1 from t1 where c1 >= 2 and c1 <= 10;
# ((103 - 5) / 200 + 0.0025) * 0.8 = 0.393
((103 - 5) / 200) * 0.8 = 0.392
select c1 from t1 where c1 > 1.5 and c1 <= 10;
((103 - 5) / 200 + 0.0025) * 0.8 = 0.393
select c1 from t1 where c1 >= 2 and c1 < 10.5;

View File

@ -0,0 +1,126 @@
******************CASE0******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_nn = 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not NULL;
SELECTIVITY = 1
******************CASE1******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e = 0.1
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1;
SELECTIVITY = 0.01
******************CASE2******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_nn = 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 0;
SELECTIVITY = 1
******************CASE3******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e + p_e = 0.2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1 or c1 = 2;
SELECTIVITY = 0.02
******************CASE4******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e = 0.1
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1;
SELECTIVITY = 0.01
******************CASE5******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e + p_e - p_e * p_e = 0.19
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1 or c2 = 1;
SELECTIVITY = 0.0199
******************CASE6******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e + p_nn - p_nn * p_e = 0.55
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 0 or c1 = 1;
SELECTIVITY = 1
******************CASE7******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e * p_e + p_e - p_e * p_e * p_e = 0.109
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1 = 1 and c2 = 1) or c1 = 2;
SELECTIVITY = 0.010099
******************CASE8******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e ^ 2 + p_e * p_nn - p_e ^ 3 * p_nn = 0.0595
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1 = 1 and c2 = 1) or (c1 = 2 and c2 > 0);
SELECTIVITY = 0.010099
******************CASE9******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :(2 * p_e - p_e * p_e) + (p_e * p_nn) - (2 * p_e - p_e * p_e) * (p_e * p_nn) = 0.2305
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1 = 1 or c2 = 1) or (c1 = 2 and c2 > 0);
SELECTIVITY = 0.029701
******************CASE10******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e ^ 2 + (p_e + p_nn - p_e * p_nn) - (p_e ^ 2 * (p_e + p_nn - p_e * p_nn)) = 0.5545
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1 = 1 and c2 = 1) or (c1 = 2 or c2 > 0);
SELECTIVITY = 1
******************CASE11******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :p_e + p_e + p_e + p_e = 0.4
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1 or c1 = 2 or c1 = 3 or c1 = 4;
SELECTIVITY = 0.04
******************CASE12******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :(p_e + p_e + p_e) + p_e - p_e * (p_e * 3) = 0.37
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1 or c1 = 2 or c1 = 3 or c2 = 4;
SELECTIVITY = 0.0397
******************CASE13******************
min = 1, max = 5, ndv = 5, null_num = 5
the ratio of not null row is (10-5)/10 = 0.5
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :((p_e + p_e) + p_e - p_e * (p_e + p_e)) + p_e - p_e * (3 * p_e - p_e * (p_e + p_e)) = 0.352
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1 or c1 = 2 or c2 = 3 or c1 = 4;
SELECTIVITY = 0.039502

View File

@ -0,0 +1,41 @@
#define p_nn = (10-5)/10 = 0.5
#define p_e = 1/5*0.5 = 0.1
p_nn = 0.5
select c1 from t1 where c1 is not NULL;
p_e = 0.1
select c1 from t1 where c1 = 1;
p_nn = 0.5
select c1 from t1 where c1 > 0;
# basic
p_e + p_e = 0.2
select c1 from t1 where c1 = 1 or c1 = 2;
p_e = 0.1
select c1 from t1 where c1 = 1;
p_e + p_e - p_e * p_e = 0.19
select c1 from t1 where c1 = 1 or c2 = 1;
p_e + p_nn - p_nn * p_e = 0.55
select c1 from t1 where c1 > 0 or c1 = 1;
# complex
# (p_e + p_e) and (p_e + p_e - p_e * p_e) = 4 * p_e ^ 2 - 2 * p_e ^ 3 = 0.038
p_e * p_e + p_e - p_e * p_e * p_e = 0.109
select c1 from t1 where (c1 = 1 and c2 = 1) or c1 = 2;
# not mutex
p_e ^ 2 + p_e * p_nn - p_e ^ 3 * p_nn = 0.0595
select c1 from t1 where (c1 = 1 and c2 = 1) or (c1 = 2 and c2 > 0);
# left c1 c2 is not mutex, other OR is mutex
(2 * p_e - p_e * p_e) + (p_e * p_nn) - (2 * p_e - p_e * p_e) * (p_e * p_nn) = 0.2305
select c1 from t1 where (c1 = 1 or c2 = 1) or (c1 = 2 and c2 > 0);
# all OR is not mutex
p_e ^ 2 + (p_e + p_nn - p_e * p_nn) - (p_e ^ 2 * (p_e + p_nn - p_e * p_nn)) = 0.5545
select c1 from t1 where (c1 = 1 and c2 = 1) or (c1 = 2 or c2 > 0);
p_e + p_e + p_e + p_e = 0.4
select c1 from t1 where c1 = 1 or c1 = 2 or c1 = 3 or c1 = 4;
(p_e + p_e + p_e) + p_e - p_e * (p_e * 3) = 0.37
select c1 from t1 where c1 = 1 or c1 = 2 or c1 = 3 or c2 = 4;
((p_e + p_e) + p_e - p_e * (p_e + p_e)) + p_e - p_e * (3 * p_e - p_e * (p_e + p_e)) = 0.352
select c1 from t1 where c1 = 1 or c1 = 2 or c2 = 3 or c1 = 4;

View File

@ -0,0 +1,873 @@
******************CASE0******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 1000 or (c1 > 2000 and c1 < 3000);
SELECTIVITY = 0.7
******************CASE1******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1;
SELECTIVITY = 1
******************CASE2******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1 > 0;
SELECTIVITY = 1
******************CASE3******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 0;
SELECTIVITY = 0
******************CASE4******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where null;
SELECTIVITY = 0
******************CASE5******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 999;
SELECTIVITY = 0.7
******************CASE6******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 10001;
SELECTIVITY = 0.7
******************CASE7******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1000;
SELECTIVITY = 0.7
******************CASE8******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.3
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <=> null;
SELECTIVITY = 0.3
******************CASE9******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = null;
SELECTIVITY = 0
******************CASE10******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 = 1000;
SELECTIVITY = 0.7
******************CASE11******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 * 2 = 1000;
SELECTIVITY = 0.7
******************CASE12******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.005(DEFAULT_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 / 2 = 1000;
SELECTIVITY = 0.005
******************CASE13******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 - 100 = 1000;
SELECTIVITY = 0.7
******************CASE14******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null;
SELECTIVITY = 0
******************CASE15******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null or 1 > 0;
SELECTIVITY = 1
******************CASE16******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null or 1 > 2;
SELECTIVITY = 0
******************CASE17******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < null;
SELECTIVITY = 0
******************CASE18******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 30;
SELECTIVITY = 0.7
******************CASE19******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 50;
SELECTIVITY = 0.7
******************CASE20******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1.0/3.0 as not calc
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 > 5;
SELECTIVITY = 0.333333
******************CASE21******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000;
SELECTIVITY = 0.7
******************CASE22******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 2000;
SELECTIVITY = 0.7
******************CASE23******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 5000;
SELECTIVITY = 0.7
******************CASE24******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 5000;
SELECTIVITY = 0.7
******************CASE25******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 500;
SELECTIVITY = 0.7
******************CASE26******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 10000;
SELECTIVITY = 0.7
******************CASE27******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != 500;
SELECTIVITY = 0.35
******************CASE28******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != 50;
SELECTIVITY = 0.35
******************CASE29******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 != 50;
SELECTIVITY = 0.35
******************CASE30******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 * 2 != 50;
SELECTIVITY = 0.35
******************CASE31******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 / 2 != 50;
SELECTIVITY = 0.5
******************CASE32******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 and c1 < 3000;
SELECTIVITY = 0.7
******************CASE33******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 10000 and c1 > 500;
SELECTIVITY = 0.7
******************CASE34******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 10000 and c1 > 500;
SELECTIVITY = 0.7
******************CASE35******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 500 or c1 > 10000;
SELECTIVITY = 0.7
******************CASE36******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or c1 < 1000;
SELECTIVITY = 0.7
******************CASE37******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
SELECTIVITY = 0.7
******************CASE38******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or (c1 < 1000 and c1 > 500);
SELECTIVITY = 0.7
******************CASE39******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1000 and c1 > 500;
SELECTIVITY = 0.7
******************CASE40******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1000 or (c1 > 9000 and c1 > 2000 and c1 < 8000);
SELECTIVITY = 0.7
******************CASE41******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 500 or (c1 > 10000 and c1 > 10001 and c1 < 499);
SELECTIVITY = 0.7
******************CASE42******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.3
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is null;
SELECTIVITY = 0.3
******************CASE43******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is false;
SELECTIVITY = 0.35
******************CASE44******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is true;
SELECTIVITY = 0.35
******************CASE45******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not null;
SELECTIVITY = 0.7
******************CASE46******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.65
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not false;
SELECTIVITY = 0.65
******************CASE47******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.65
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not true;
SELECTIVITY = 0.65
******************CASE48******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select * from t1 where not 1;
SELECTIVITY = 0
******************CASE49******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select * from t1 where not 0;
SELECTIVITY = 1
******************CASE50******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7;
----------------------------------------------------------
EXPR_STR: select * from t1 where not c1 > 2000;
SELECTIVITY = 0.7
******************CASE51******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select * from t1 where not (c1 > 2000 and c1 < 3000);
SELECTIVITY = 0.7
******************CASE52******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35;
----------------------------------------------------------
EXPR_STR: select * from t1 where not c1 in (2000, 3000);
SELECTIVITY = 0.35
******************CASE53******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1/500*0.99 * 3;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 in (500, 8000, 10000);
SELECTIVITY = 1
******************CASE54******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select square(1/500*0.99) * 2
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
SELECTIVITY = 0.98
******************CASE55******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 200);
SELECTIVITY = 1
******************CASE56******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 300, 400, 200);
SELECTIVITY = 1
******************CASE57******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 300, 400, 500);
SELECTIVITY = 0
******************CASE58******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (c1, 300, 400, 500);
SELECTIVITY = 0.7
******************CASE59******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1) in (c1, 300, 400, 500);
SELECTIVITY = 1
******************CASE60******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not in (500, 8000, 10000);
SELECTIVITY = 0.35
******************CASE61******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not in (500, 1000);
SELECTIVITY = 0.35
******************CASE62******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.02
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
SELECTIVITY = 0.02
******************CASE63******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 1000 and 10000;
SELECTIVITY = 0.7
******************CASE64******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 1000 and 10000;
SELECTIVITY = 0.7
******************CASE65******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 1000 and 1000;
SELECTIVITY = 0.7
******************CASE66******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 1000 and 1000;
SELECTIVITY = 0.7
******************CASE67******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 10000 and 1000;
SELECTIVITY = 0
******************CASE68******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 10000 and 1000;
SELECTIVITY = 0.7
******************CASE69******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 10000 and c1<=1000;
SELECTIVITY = 0
******************CASE70******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 between c1 and 1000;
SELECTIVITY = 0.7
******************CASE71******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 not between c1 and 1000;
SELECTIVITY = 0.333333
******************CASE72******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 between 10000 and c1;
SELECTIVITY = 0.7
******************CASE73******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 2000 between 1000 and c1;
SELECTIVITY = 0.7
******************CASE74******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1 between 0 and 1;
SELECTIVITY = 1
******************CASE75******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 100 between 0 and 1;
SELECTIVITY = 0
******************CASE76******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 = t2.c1;
SELECTIVITY = 0.49
******************CASE77******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
SELECTIVITY = 0.7
******************CASE78******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
SELECTIVITY = 0.7
******************CASE79******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
SELECTIVITY = 0.7
******************CASE80******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.005(DEFAULT_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
SELECTIVITY = 0.005
******************CASE81******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7 * (1/3);
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
SELECTIVITY = 0.163333
******************CASE82******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1/3;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1, t2 where t1.c1 < t2.c2;
SELECTIVITY = 0.333333
******************CASE83******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.5;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1, t2 where t1.c1 != t2.c2;
SELECTIVITY = 0.5
******************CASE84******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.7
******************CASE85******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 1.0 / 3.0 (DEFAULT_INEQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.333333
******************CASE86******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. 0.35
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.35
******************CASE87******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
SELECTIVITY = 0.5
******************CASE88******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE89******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE90******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE91******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE92******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE93******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE94******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7 * 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) = (2000, 10000);
SELECTIVITY = 0.49
******************CASE95******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :todo. 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) != (2000, 10000);
SELECTIVITY = 0.5
******************CASE96******************
min = 1000, max = 1000, ndv = 1, null_num = 3000
the ratio of not null row is (10000-3000)/10000 = 0.7
for range cond : if half_open min_selectivity = 20/DNV, else min_selectivity = 10/DNV
EXPECTED RESULT :select 0.7
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) > (2000, 10000);
SELECTIVITY = 0.7

View File

@ -0,0 +1,212 @@
#select c1 from t1 where c1 between 10000 and 1000;
#select c1 from t1 where c1 not in (500, 1000)
#select c1 from t1 where (c1, c2) = (2000, 10000);
#select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
#select c1 from t1 where c1 = 1000;
select 0.7.
select c1 from t1 where c1 > 1000 or (c1 > 2000 and c1 < 3000);
# const
select 1;
select c1 from t1 where 1;
select 1;
select c1 from t1 where 1 > 0;
select 0;
select c1 from t1 where 0;
select 0;
select c1 from t1 where null;
# distinct(1000), min(500), max(10000), nullnum(100)
#equal a = 1
select 0.7;
select c1 from t1 where c1 = 999;
select 0.7;
select c1 from t1 where c1 = 10001;
select 0.7;
select c1 from t1 where c1 = 1000;
select 0.3
select c1 from t1 where c1 <=> null;
select 0
select c1 from t1 where c1 = null;
select 0.7;
select c1 from t1 where c1 + 1 = 1000;
select 0.7;
select c1 from t1 where c1 * 2 = 1000;
select 0.005(DEFAULT_EQ_SEL)
select c1 from t1 where c1 / 2 = 1000;
select 0.7;
select c1 from t1 where c1 - 100 = 1000;
# range cond
select 0;
select c1 from t1 where c1 > null;
select 1;
select c1 from t1 where c1 > null or 1 > 0;
select 0;
select c1 from t1 where c1 > null or 1 > 2;
select 0;
select c1 from t1 where c1 < null;
select 0.7;
select c1 from t1 where c1 > 30;
select 0.7;
select c1 from t1 where c1 < 50;
select 1.0/3.0 as not calc
select c1 from t1 where c1 + 1 > 5;
select 0.7;
select c1 from t1 where c1 > 2000;
select 0.7;
select c1 from t1 where c1 >= 2000;
select 0.7;
select c1 from t1 where c1 < 5000;
select 0.7;
select c1 from t1 where c1 <= 5000;
select 0.7;
select c1 from t1 where c1 <= 500;
select 0.7;
select c1 from t1 where c1 >= 10000;
select 0.35
select c1 from t1 where c1 != 500;
select 0.35
select c1 from t1 where c1 != 50;
select 0.35
select c1 from t1 where c1 + 1 != 50;
select 0.35
select c1 from t1 where c1 * 2 != 50;
select 0.35
select c1 from t1 where c1 / 2 != 50;
select 0.7
select c1 from t1 where c1 > 2000 and c1 < 3000;
select 0.7
select c1 from t1 where c1 > 10000 and c1 > 500;
select 0.7
select c1 from t1 where c1 < 10000 and c1 > 500;
select 0.7(should be)
select c1 from t1 where c1 < 500 or c1 > 10000;
select 0.7(should be)
select c1 from t1 where c1 > 2000 or c1 < 1000;
select 0.7(should be)
select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
select 0.7(should be)
select c1 from t1 where c1 > 2000 or (c1 < 1000 and c1 > 500);
select 0.7
select c1 from t1 where c1 < 1000 and c1 > 500;
select 0.7
select c1 from t1 where c1 < 1000 or (c1 > 9000 and c1 > 2000 and c1 < 8000);
select 0.7
select c1 from t1 where c1 < 500 or (c1 > 10000 and c1 > 10001 and c1 < 499);
#T_OP_IS
select 0.3
select c1 from t1 where c1 is null;
select 0.35
select c1 from t1 where c1 is false;
select 0.35
select c1 from t1 where c1 is true;
#T_OP_NOT
select 0.7
select c1 from t1 where c1 is not null;
select 0.65
select c1 from t1 where c1 is not false;
select 0.65
select c1 from t1 where c1 is not true;
select 0
select * from t1 where not 1;
select 1;
select * from t1 where not 0;
select 0.7;
select * from t1 where not c1 > 2000;
select 0.7(should be)
select * from t1 where not (c1 > 2000 and c1 < 3000);
select 0.35;
select * from t1 where not c1 in (2000, 3000);
#T_OP_IN
select 1/500*0.99 * 3;
select c1 from t1 where c1 in (500, 8000, 10000);
select square(1/500*0.99) * 2
select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
# const in const
select 1;
select c1 from t1 where (200) in (100, 200);
select 1;
select c1 from t1 where (200) in (100, 300, 400, 200);
select 0;
select c1 from t1 where (200) in (100, 300, 400, 500);
select 1;
select c1 from t1 where (200) in (c1, 300, 400, 500);
select 1;
select c1 from t1 where (c1) in (c1, 300, 400, 500);
select 0.35
select c1 from t1 where c1 not in (500, 8000, 10000);
select 0.35
select c1 from t1 where c1 not in (500, 1000);
select 0.02
select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
#BTW, NOT BTW
select 0.7
select c1 from t1 where c1 between 1000 and 10000;
select 0.7(should be)
select c1 from t1 where c1 not between 1000 and 10000;
select 0.7
select c1 from t1 where c1 between 1000 and 1000;
select 0.7(should be)
select c1 from t1 where c1 not between 1000 and 1000;
select 0;
select c1 from t1 where c1 between 10000 and 1000;
select 0.7(should be)
select c1 from t1 where c1 not between 10000 and 1000;
select 0;
select c1 from t1 where c1 >= 10000 and c1<=1000;
select 0.7
select c1 from t1 where 1000 between c1 and 1000;
select 0.7
select c1 from t1 where 1000 not between c1 and 1000;
select 0
select c1 from t1 where 1000 between 10000 and c1;
select 0.7
select c1 from t1 where 2000 between 1000 and c1;
select 1;
select c1 from t1 where 1 between 0 and 1;
select 0;
select c1 from t1 where 100 between 0 and 1;
#JOIN COND
# min(basic_sel1, basic_sel2)
select 0.7
select t1.c1 from t1,t2 where t1.c1 = t2.c1;
select 0.7
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
select 0.7
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
select 0.7
select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
select 0.005(DEFAULT_EQ_SEL)
select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
select 0.7 * (1/3);
select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
select 1/3;
select t1.c1 from t1, t2 where t1.c1 < t2.c2;
select 0.5;
select t1.c1 from t1, t2 where t1.c1 != t2.c2;
# IS_WITH_SUBQUERY
select 0.7
select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
select 1.0 / 3.0 (DEFAULT_INEQ_SEL)
select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
todo. 0.35
select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
#ROW
select 0.7 * 0.7
select c1 from t1 where (c1, c2) = (2000, 10000);
todo. 0.5
select c1 from t1 where (c1, c2) != (2000, 10000);
select 0.7
select c1 from t1 where (c1, c2) > (2000, 10000);

View File

@ -0,0 +1,24 @@
EXPR_STR: select * from t1,t2 where t1.c1 = t2.c1;
table1 SELECTIVITY = 0.0007125
table2 SELECTIVITY = 0.0007125
EXPR_STR: select * from t1,t2 where t1.c1 = t2.c1 or t1.c1 > 1;
table1 SELECTIVITY = 0.950036
table2 SELECTIVITY = 0.950036
EXPR_STR: select * from t1,t2 where t1.c1 = t2.c1 and t1.c1 > 1;
table1 SELECTIVITY = 0.000676875
table2 SELECTIVITY = 0.000676875
EXPR_STR: select * from t1,t2 where t1.c1 < t2.c1;
table1 SELECTIVITY = 0.333333
table2 SELECTIVITY = 0.333333
EXPR_STR: select * from t1,t2 where t1.c1 > t2.c1;
table1 SELECTIVITY = 0.333333
table2 SELECTIVITY = 0.333333
EXPR_STR: select * from t1,t2 where t1.c1 != t2.c1;
table1 SELECTIVITY = 0.5
table2 SELECTIVITY = 0.5

View File

@ -0,0 +1,11 @@
#table1 B1
#table2 B2
select * from t1,t2 where t1.c1 = t2.c1;
#table1 B1 + A1 * 1 - B1*A1
#table2 B2 + A1 * 1 - B2*A1
select * from t1,t2 where t1.c1 = t2.c1 or t1.c1 > 1;
select * from t1,t2 where t1.c1 = t2.c1 and t1.c1 > 1;
#DEFAULT_INEQ_SEL
select * from t1,t2 where t1.c1 < t2.c1;
select * from t1,t2 where t1.c1 > t2.c1;
select * from t1,t2 where t1.c1 != t2.c1;

View File

@ -0,0 +1,120 @@
EXPR_STR: select c1 from t3 where c1 like '|||%';
SELECTIVITY = 0.0200001
EXPR_STR: select c1 from t3 where c1 like '11';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 > '|||||||||||||||||||2';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 = '11';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 != '11';
SELECTIVITY = 0.99
EXPR_STR: select c1 from t3 where c1 > '11';
SELECTIVITY = 0.996844
EXPR_STR: select c1 from t3 where c1 < '11';
SELECTIVITY = 0.0231557
EXPR_STR: select c1 from t3 where c1 < '|||||||||||||||||||2';
SELECTIVITY = 1
EXPR_STR: select c1 from t3 where c1 > '|||||||||||||||||||2';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 > '||||||||||||||||||||';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 > '20150305123445555';
SELECTIVITY = 0.984024
EXPR_STR: select c1 from t3 where c1 > '20150305123445555';
SELECTIVITY = 0.984024
EXPR_STR: select c1 from t3 where c1 like '11';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 like 'abc';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 like '|||%';
SELECTIVITY = 0.0200001
EXPR_STR: select c1 from t3 where c1 like 123;
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 like 's%123' escape 's';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 like '123';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 like '%123';
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t3 where c1 like '%%';
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t3 where c1 like '%||||%';
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t3 where c1 like '%|||';
SELECTIVITY = 0.333333
EXPR_STR: select c1 from t3 where c1 > '20150305123445555';
SELECTIVITY = 0.897209
EXPR_STR: select c1 from t3 where c1 < '20150305123445555';
SELECTIVITY = 0.122791
EXPR_STR: select c1 from t3 where c1 < '99991231235959999';
SELECTIVITY = 1
EXPR_STR: select c1 from t3 where c1 > '99991231235959999';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 < '10000101000000111';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 > '10000101000000111';
SELECTIVITY = 1
EXPR_STR: select c1 from t3 where c1 > '10000101000000111' and c1 < '99991231235959999';
SELECTIVITY = 0.99
EXPR_STR: select c1 from t3 where c1 > '20150305123445555' and c1 < '10000101000000111';
SELECTIVITY = 0
EXPR_STR: select c1 from t3 where c1 < '20150305123445555' and c1 > '99991231235959999';
SELECTIVITY = 0
EXPR_STR: select c1 from t3 where c1 > '20150305123445555' and c1 < '50120805123445666';
SELECTIVITY = 0.323038
EXPR_STR: select c1 from t3 where c1 > '20150305123445555' and c1 < '20150305123446666';
SELECTIVITY = 0
EXPR_STR: select c1 from t3 where c1 = '20150305123445555';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 != '20150305123445555';
SELECTIVITY = 0.99
EXPR_STR: select c1 from t3 where c1 like '20150305123445555';
SELECTIVITY = 0.01
EXPR_STR: select c1 from t3 where c1 like '1000%';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 like '9999%';
SELECTIVITY = 0.02
EXPR_STR: select c1 from t3 where c1 like '1%';
SELECTIVITY = 0.119323
EXPR_STR: select c1 from t3 where c1 like '99%';
SELECTIVITY = 0.0201236

View File

@ -0,0 +1,46 @@
select c1 from t3 where c1 like '|||%';
select c1 from t3 where c1 like '11';
#range cond
select c1 from t3 where c1 > '|||||||||||||||||||2';
select c1 from t3 where c1 = '11';
select c1 from t3 where c1 != '11';
select c1 from t3 where c1 > '11';
select c1 from t3 where c1 < '11';
select c1 from t3 where c1 < '|||||||||||||||||||2';
select c1 from t3 where c1 > '|||||||||||||||||||2';
select c1 from t3 where c1 > '||||||||||||||||||||';
select c1 from t3 where c1 > '20150305123445555';
select c1 from t3 where c1 > '20150305123445555';
#like
select c1 from t3 where c1 like '11';
select c1 from t3 where c1 like 'abc';
select c1 from t3 where c1 like '|||%';
select c1 from t3 where c1 like 123;
select c1 from t3 where c1 like 's%123' escape 's';
select c1 from t3 where c1 like '123';
select c1 from t3 where c1 like '%123';
select c1 from t3 where c1 like '%%';
select c1 from t3 where c1 like '%||||%';
select c1 from t3 where c1 like '%|||';
# test datetime
datetime
select c1 from t3 where c1 > '20150305123445555';
select c1 from t3 where c1 < '20150305123445555';
select c1 from t3 where c1 < '99991231235959999';
select c1 from t3 where c1 > '99991231235959999';
select c1 from t3 where c1 < '10000101000000111';
select c1 from t3 where c1 > '10000101000000111';
select c1 from t3 where c1 > '10000101000000111' and c1 < '99991231235959999';
select c1 from t3 where c1 > '20150305123445555' and c1 < '10000101000000111';
select c1 from t3 where c1 < '20150305123445555' and c1 > '99991231235959999';
select c1 from t3 where c1 > '20150305123445555' and c1 < '50120805123445666';
select c1 from t3 where c1 > '20150305123445555' and c1 < '20150305123446666';
select c1 from t3 where c1 = '20150305123445555';
select c1 from t3 where c1 != '20150305123445555';
select c1 from t3 where c1 like '20150305123445555';
select c1 from t3 where c1 like '1000%';
select c1 from t3 where c1 like '9999%';
select c1 from t3 where c1 like '1%';
select c1 from t3 where c1 like '99%';

View File

@ -0,0 +1,776 @@
******************CASE0******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0.2 HALF_OPEN_RANGE_SEL.
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 1000 or (c1 > 2000 and c1 < 3000);
SELECTIVITY = 0.2
******************CASE1******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1;
SELECTIVITY = 1
******************CASE2******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1 > 0;
SELECTIVITY = 1
******************CASE3******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 0;
SELECTIVITY = 0
******************CASE4******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where null;
SELECTIVITY = 0
******************CASE5******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 999;
SELECTIVITY = 0.00198
******************CASE6******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 10001;
SELECTIVITY = 0.00198
******************CASE7******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = 1000;
SELECTIVITY = 0.00198
******************CASE8******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0.01
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <=> null;
SELECTIVITY = 0.01
******************CASE9******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = null;
SELECTIVITY = 0
******************CASE10******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 = 1000;
SELECTIVITY = 0.00198
******************CASE11******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 * 2 = 1000;
SELECTIVITY = 0.00198
******************CASE12******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0.005(DEFAULT_EQ_SEL)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 / 2 = 1000;
SELECTIVITY = 0.005
******************CASE13******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/500*0.99;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 - 100 = 1000;
SELECTIVITY = 0.00198
******************CASE14******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null;
SELECTIVITY = 0
******************CASE15******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null or 1 > 0;
SELECTIVITY = 1
******************CASE16******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > null or 1 > 2;
SELECTIVITY = 0
******************CASE17******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < null;
SELECTIVITY = 0
******************CASE18******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 30;
SELECTIVITY = 0.2
******************CASE19******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 50;
SELECTIVITY = 0.2
******************CASE20******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1.0/3.0 as not calc
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 > 5;
SELECTIVITY = 0.333333
******************CASE21******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000;
SELECTIVITY = 0.2
******************CASE22******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 2000;
SELECTIVITY = 0.2
******************CASE23******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 5000;
SELECTIVITY = 0.2
******************CASE24******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 5000;
SELECTIVITY = 0.2
******************CASE25******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 <= 500;
SELECTIVITY = 0.2
******************CASE26******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 10000;
SELECTIVITY = 0.2
******************CASE27******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != 500;
SELECTIVITY = 0.98802
******************CASE28******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != 50;
SELECTIVITY = 0.98802
******************CASE29******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 + 1 != 50;
SELECTIVITY = 0.98802
******************CASE30******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 * 2 != 50;
SELECTIVITY = 0.98802
******************CASE31******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 / 2 != 50;
SELECTIVITY = 0.5
******************CASE32******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 and c1 < 3000;
SELECTIVITY = 0.0099
******************CASE33******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 10000 and c1 > 500;
SELECTIVITY = 0.2
******************CASE34******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 10000 and c1 > 500;
SELECTIVITY = 0.0099
******************CASE35******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 500 or c1 > 10000;
SELECTIVITY = 0.4
******************CASE36******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or c1 < 1000;
SELECTIVITY = 0.4
******************CASE37******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
SELECTIVITY = 0.4
******************CASE38******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > 2000 or (c1 < 1000 and c1 > 500);
SELECTIVITY = 0.2099
******************CASE39******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1000 and c1 > 500;
SELECTIVITY = 0.0099
******************CASE40******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 1000 or (c1 > 9000 and c1 > 2000 and c1 < 8000);
SELECTIVITY = 0.2
******************CASE41******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 < 500 or (c1 > 10000 and c1 > 10001 and c1 < 499);
SELECTIVITY = 0.2
******************CASE42******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is null;
SELECTIVITY = 0.01
******************CASE43******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is false;
SELECTIVITY = 0.00198
******************CASE44******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is true;
SELECTIVITY = 0.98802
******************CASE45******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not null;
SELECTIVITY = 0.99
******************CASE46******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not false;
SELECTIVITY = 0.99802
******************CASE47******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 is not true;
SELECTIVITY = 0.01198
******************CASE48******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select * from t1 where not 1;
SELECTIVITY = 0
******************CASE49******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select * from t1 where not 0;
SELECTIVITY = 1
******************CASE50******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select * from t1 where not c1 > 2000;
SELECTIVITY = 0.2
******************CASE51******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select * from t1 where not (c1 > 2000 and c1 < 3000);
SELECTIVITY = 0.4
******************CASE52******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select * from t1 where not c1 in (2000, 3000);
SELECTIVITY = 0.98604
******************CASE53******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 in (500, 8000, 10000);
SELECTIVITY = 0.00594
******************CASE54******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
SELECTIVITY = 7.8408e-06
******************CASE55******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 200);
SELECTIVITY = 1
******************CASE56******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 300, 400, 200);
SELECTIVITY = 1
******************CASE57******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (100, 300, 400, 500);
SELECTIVITY = 0
******************CASE58******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (200) in (c1, 300, 400, 500);
SELECTIVITY = 0.00198
******************CASE59******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1) in (c1, 300, 400, 500);
SELECTIVITY = 0.99594
******************CASE60******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not in (500, 8000, 10000);
SELECTIVITY = 0.98406
******************CASE61******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not in (500, 1000);
SELECTIVITY = 0.98604
******************CASE62******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0(should be)
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
SELECTIVITY = 0.999992
******************CASE63******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 1000 and 10000;
SELECTIVITY = 0.0099
******************CASE64******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 1000 and 10000;
SELECTIVITY = 0.4
******************CASE65******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 1000 and 1000;
SELECTIVITY = 0.00198
******************CASE66******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 1000 and 1000;
SELECTIVITY = 0.4
******************CASE67******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 between 10000 and 1000;
SELECTIVITY = 0
******************CASE68******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 not between 10000 and 1000;
SELECTIVITY = 0.2
******************CASE69******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 >= 10000 and c1<=1000;
SELECTIVITY = 0
******************CASE70******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 between c1 and 1000;
SELECTIVITY = 0.2
******************CASE71******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 not between c1 and 1000;
SELECTIVITY = 0.333333
******************CASE72******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1000 between 10000 and c1;
SELECTIVITY = 0.2
******************CASE73******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 2000 between 1000 and c1;
SELECTIVITY = 0.2
******************CASE74******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 1 between 0 and 1;
SELECTIVITY = 1
******************CASE75******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where 100 between 0 and 1;
SELECTIVITY = 0
******************CASE76******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 = t2.c1;
SELECTIVITY = 0.0019602
******************CASE77******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
SELECTIVITY = 0.00198
******************CASE78******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
SELECTIVITY = 0.00198
******************CASE79******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
SELECTIVITY = 0.00198
******************CASE80******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
SELECTIVITY = 0.00198
******************CASE81******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
SELECTIVITY = 0.0006534
******************CASE82******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1/3;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1, t2 where t1.c1 < t2.c2;
SELECTIVITY = 0.333333
******************CASE83******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0.5;
----------------------------------------------------------
EXPR_STR: select t1.c1 from t1, t2 where t1.c1 != t2.c2;
SELECTIVITY = 0.5
******************CASE84******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.00198
******************CASE85******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 1.0 / 3.0 DEFAULT_INEQ_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.333333
******************CASE86******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
SELECTIVITY = 0.98802
******************CASE87******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
SELECTIVITY = 0.5
******************CASE88******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE89******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE90******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE91******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE92******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE93******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. DEFAULT_SEL
----------------------------------------------------------
EXPR_STR: select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
SELECTIVITY = 0.5
******************CASE94******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) = (2000, 10000);
SELECTIVITY = 3.9204e-06
******************CASE95******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :todo. 0.5
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) != (2000, 10000);
SELECTIVITY = 0.5
******************CASE96******************
min = MIN, max = MAX, ndv = 0, null_num = 10000
the ratio of not null row is 0.0
EXPECTED RESULT :select 0;
----------------------------------------------------------
EXPR_STR: select c1 from t1 where (c1, c2) > (2000, 10000);
SELECTIVITY = 0.2

View File

@ -0,0 +1,212 @@
#select c1 from t1 where c1 between 10000 and 1000;
#select c1 from t1 where c1 not in (500, 1000)
#select c1 from t1 where (c1, c2) = (2000, 10000);
#select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
#select c1 from t1 where c1 = 1000;
select 0.2 HALF_OPEN_RANGE_SEL.
select c1 from t1 where c1 > 1000 or (c1 > 2000 and c1 < 3000);
# const
select 1;
select c1 from t1 where 1;
select 1;
select c1 from t1 where 1 > 0;
select 0;
select c1 from t1 where 0;
select 0;
select c1 from t1 where null;
# distinct(1000), min(500), max(10000), nullnum(100)
#equal a = 1
select 1/500*0.99;
select c1 from t1 where c1 = 999;
select 1/500*0.99;
select c1 from t1 where c1 = 10001;
select 1/500*0.99;
select c1 from t1 where c1 = 1000;
select 0.01
select c1 from t1 where c1 <=> null;
select 0
select c1 from t1 where c1 = null;
select 1/500*0.99;
select c1 from t1 where c1 + 1 = 1000;
select 1/500*0.99;
select c1 from t1 where c1 * 2 = 1000;
select 0.005(DEFAULT_EQ_SEL)
select c1 from t1 where c1 / 2 = 1000;
select 1/500*0.99;
select c1 from t1 where c1 - 100 = 1000;
# range cond
select 0;
select c1 from t1 where c1 > null;
select 1;
select c1 from t1 where c1 > null or 1 > 0;
select 0;
select c1 from t1 where c1 > null or 1 > 2;
select 0;
select c1 from t1 where c1 < null;
select 0;
select c1 from t1 where c1 > 30;
select 0;
select c1 from t1 where c1 < 50;
select 1.0/3.0 as not calc
select c1 from t1 where c1 + 1 > 5;
select 0;
select c1 from t1 where c1 > 2000;
select 0;
select c1 from t1 where c1 >= 2000;
select 0;
select c1 from t1 where c1 < 5000;
select 0;
select c1 from t1 where c1 <= 5000;
select 0;
select c1 from t1 where c1 <= 500;
select 0;
select c1 from t1 where c1 >= 10000;
select 0;
select c1 from t1 where c1 != 500;
select 0;
select c1 from t1 where c1 != 50;
select 0;
select c1 from t1 where c1 + 1 != 50;
select 0;
select c1 from t1 where c1 * 2 != 50;
select 0.5
select c1 from t1 where c1 / 2 != 50;
select 0
select c1 from t1 where c1 > 2000 and c1 < 3000;
select 0
select c1 from t1 where c1 > 10000 and c1 > 500;
select 0
select c1 from t1 where c1 < 10000 and c1 > 500;
select 0
select c1 from t1 where c1 < 500 or c1 > 10000;
select 0
select c1 from t1 where c1 > 2000 or c1 < 1000;
select 0
select c1 from t1 where c1 > 2000 or c1 < 1000 or c1 < 500;
select 0
select c1 from t1 where c1 > 2000 or (c1 < 1000 and c1 > 500);
select 0
select c1 from t1 where c1 < 1000 and c1 > 500;
select 0
select c1 from t1 where c1 < 1000 or (c1 > 9000 and c1 > 2000 and c1 < 8000);
select 0
select c1 from t1 where c1 < 500 or (c1 > 10000 and c1 > 10001 and c1 < 499);
#T_OP_IS
select 1
select c1 from t1 where c1 is null;
select 0;
select c1 from t1 where c1 is false;
select 0
select c1 from t1 where c1 is true;
#T_OP_NOT
select 0
select c1 from t1 where c1 is not null;
select 1
select c1 from t1 where c1 is not false;
select 1
select c1 from t1 where c1 is not true;
select 0;
select * from t1 where not 1;
select 1;
select * from t1 where not 0;
select 0;
select * from t1 where not c1 > 2000;
select 0;
select * from t1 where not (c1 > 2000 and c1 < 3000);
select 0;
select * from t1 where not c1 in (2000, 3000);
#T_OP_IN
select 0;
select c1 from t1 where c1 in (500, 8000, 10000);
select 0;
select c1 from t1 where (c1,c2) in ((500, 8000), (8000, 10000));
# const in const
select 1;
select c1 from t1 where (200) in (100, 200);
select 1;
select c1 from t1 where (200) in (100, 300, 400, 200);
select 0;
select c1 from t1 where (200) in (100, 300, 400, 500);
select 1;
select c1 from t1 where (200) in (c1, 300, 400, 500);
select 0;
select c1 from t1 where (c1) in (c1, 300, 400, 500);
select 0;
select c1 from t1 where c1 not in (500, 8000, 10000);
select 0;
select c1 from t1 where c1 not in (500, 1000);
select 0(should be)
select c1 from t1 where (c1,c2) not in ((500, 8000), (8000, 10000));
#BTW, NOT BTW
select 0;
select c1 from t1 where c1 between 1000 and 10000;
select 0;
select c1 from t1 where c1 not between 1000 and 10000;
select 0;
select c1 from t1 where c1 between 1000 and 1000;
select 0;
select c1 from t1 where c1 not between 1000 and 1000;
select 0;
select c1 from t1 where c1 between 10000 and 1000;
select 0;
select c1 from t1 where c1 not between 10000 and 1000;
select 0;
select c1 from t1 where c1 >= 10000 and c1<=1000;
select 0;
select c1 from t1 where 1000 between c1 and 1000;
select 0;
select c1 from t1 where 1000 not between c1 and 1000;
select 0;
select c1 from t1 where 1000 between 10000 and c1;
select 0;
select c1 from t1 where 2000 between 1000 and c1;
select 1;
select c1 from t1 where 1 between 0 and 1;
select 0;
select c1 from t1 where 100 between 0 and 1;
#JOIN COND
# min(basic_sel1, basic_sel2)
select 0;
select t1.c1 from t1,t2 where t1.c1 = t2.c1;
select 0;
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1;
select 0;
select t1.c1 from t1,t2 where t1.c1 + 1 = t2.c1 + 1;
select 0;
select t1.c1 from t1,t2 where t1.c1 * 2 = t2.c1 + 1;
select 0;
select t1.c1 from t1,t2 where t1.c1 / 2 = t2.c1 + 1;
select 0;
select t1.c1 from t1,t2 where t1.c1 = t2.c1 and t1.c2 > t2.c2;
select 1/3;
select t1.c1 from t1, t2 where t1.c1 < t2.c2;
select 0.5;
select t1.c1 from t1, t2 where t1.c1 != t2.c2;
# IS_WITH_SUBQUERY
select 0;
select c1 from t1 where c1 = (select c2 from t1 where c2 >= 10000);
select 1.0 / 3.0 DEFAULT_INEQ_SEL
select c1 from t1 where c1 > (select c2 from t1 where c2 >= 10000);
select 0;
select c1 from t1 where c1 != (select c2 from t1 where c2 >= 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 in (select c2 from t1 where c2 = 10000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ANY (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != SOME (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 = ALL (select c2 from t1 where c2 > 1000);
todo. DEFAULT_SEL
select c1 from t1 where c1 != ALL (select c2 from t1 where c2 > 1000);
#ROW
select 0;
select c1 from t1 where (c1, c2) = (2000, 10000);
todo. 0.5
select c1 from t1 where (c1, c2) != (2000, 10000);
select 0;
select c1 from t1 where (c1, c2) > (2000, 10000);