108 lines
4.0 KiB
Plaintext
108 lines
4.0 KiB
Plaintext
drop table if exists t1;
|
|
CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL,
|
|
f_char1 CHAR(10),
|
|
f_char2 CHAR(10), f_charbig VARCHAR(1000),
|
|
PRIMARY KEY (f_int1,f_int2))
|
|
ENGINE = NDB
|
|
PARTITION BY LIST(MOD(f_int1 + f_int2,4))
|
|
(PARTITION part_3 VALUES IN (-3),
|
|
PARTITION part_2 VALUES IN (-2),
|
|
PARTITION part_1 VALUES IN (-1),
|
|
PARTITION part0 VALUES IN (0),
|
|
PARTITION part1 VALUES IN (1),
|
|
PARTITION part2 VALUES IN (2),
|
|
PARTITION part3 VALUES IN (3,4,5));
|
|
INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20===';
|
|
INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
|
|
INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
|
|
INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
|
|
INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
|
|
INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
|
|
INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1===';
|
|
SELECT * FROM t1 ORDER BY f_int1;
|
|
f_int1 f_int2 f_char1 f_char2 f_charbig
|
|
-2 20 20 20 ===20===
|
|
1 1 1 1 ===1===
|
|
2 1 1 1 ===1===
|
|
3 1 1 1 ===1===
|
|
4 1 1 1 ===1===
|
|
5 1 1 1 ===1===
|
|
20 1 1 1 ===1===
|
|
DROP TABLE t1;
|
|
create table t1 ( a int, b int, c int, primary key (a,b)) engine=ndb
|
|
partition by list (a)
|
|
(partition part0 values in (0,1,2),
|
|
partition part1 values in (3,4,5));
|
|
insert into t1 values (0, 0, 0);
|
|
insert into t1 values (0, 1, 1);
|
|
insert into t1 values (0, 2, 2);
|
|
insert into t1 values (1, 0, 3);
|
|
insert into t1 values (1, 1, 4);
|
|
insert into t1 values (1, 2, 5);
|
|
insert into t1 values (4, 0, 6);
|
|
insert into t1 values (4, 1, 7);
|
|
insert into t1 values (4, 2, 8);
|
|
All partitions scan
|
|
select * from t1 order by c;
|
|
a b c
|
|
0 0 0
|
|
0 1 1
|
|
0 2 2
|
|
1 0 3
|
|
1 1 4
|
|
1 2 5
|
|
4 0 6
|
|
4 1 7
|
|
4 2 8
|
|
ndb_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
ndb_pruned_scan_count
|
|
0
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
Single partition scan
|
|
select * from t1 where a=0 order by c;
|
|
a b c
|
|
0 0 0
|
|
0 1 1
|
|
0 2 2
|
|
ndb_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
ndb_pruned_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
Single partition scan
|
|
select * from t1 where a=4 order by c;
|
|
a b c
|
|
4 0 6
|
|
4 1 7
|
|
4 2 8
|
|
ndb_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
ndb_pruned_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
MRR single partition scan
|
|
select * from t1 where a in (0, 2) order by c;
|
|
a b c
|
|
0 0 0
|
|
0 1 1
|
|
0 2 2
|
|
ndb_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
ndb_pruned_scan_count
|
|
1
|
|
Warnings:
|
|
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
drop table t1;
|