!2774 添加List分区的partitionmap排序
Merge pull request !2774 from chenxiaobin/addListSort
This commit is contained in:
@ -1688,6 +1688,8 @@ static void BuildListPartitionMap(Relation relation, Form_pg_partition partition
|
||||
list_itr++;
|
||||
}
|
||||
|
||||
qsort(list_eles, list_map->listElementsNum, sizeof(ListPartElement), ListElementCmp);
|
||||
|
||||
/* list element array back in RangePartitionMap */
|
||||
old_context = MemoryContextSwitchTo(LocalMyDBCacheMemCxt());
|
||||
|
||||
@ -2732,6 +2734,15 @@ int rangeElementCmp(const void* a, const void* b)
|
||||
return partitonKeyCompare((Const**)rea->boundary, (Const**)reb->boundary, rea->len);
|
||||
}
|
||||
|
||||
int ListElementCmp(const void* a, const void* b)
|
||||
{
|
||||
const ListPartElement* rea = (const ListPartElement*)a;
|
||||
const ListPartElement* reb = (const ListPartElement*)b;
|
||||
|
||||
/* just compare the first boundary */
|
||||
return partitonKeyCompare((Const**)rea->boundary, (Const**)reb->boundary, 1);
|
||||
}
|
||||
|
||||
int HashElementCmp(const void* a, const void* b)
|
||||
{
|
||||
const HashPartElement* rea = (const HashPartElement*)a;
|
||||
|
@ -513,6 +513,7 @@ int ValueCmpLowBoudary(Const** partKeyValue, const RangeElement* partition, Inte
|
||||
extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
|
||||
extern RangeElement* copyRangeElements(RangeElement* src, int elementNum, int partkeyNum);
|
||||
extern int rangeElementCmp(const void* a, const void* b);
|
||||
extern int ListElementCmp(const void* a, const void* b);
|
||||
extern int HashElementCmp(const void* a, const void* b);
|
||||
extern void DestroyListElements(ListPartElement* src, int elementNum);
|
||||
extern void PartitionMapDestroyHashArray(HashPartElement* hashArray, int arrLen);
|
||||
|
@ -505,17 +505,16 @@ select * from pg_get_tabledef('list_hash_2');
|
||||
CREATE INDEX list_hash_2_idx3 ON list_hash_2 USING btree (col_4) TABLESPACE pg_default; +
|
||||
CREATE INDEX list_hash_2_idx2 ON list_hash_2 USING btree (col_3, col_1) LOCAL( +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_list_7_subpartdefault1_col_3_col_1_idx +
|
||||
SUBPARTITION p_hash_1_3_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_1_2_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_1_1_col_3_col_1_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_6_5_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_4_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_3_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_2_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_1_col_3_col_1_idx +
|
||||
SUBPARTITION p_list_2_subpartdefault1_col_3_col_1_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_list_5_subpartdefault1_col_3_col_1_idx +
|
||||
SUBPARTITION p_hash_3_2_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_3_1_col_3_col_1_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_4_5_col_3_col_1_idx, +
|
||||
@ -525,31 +524,31 @@ select * from pg_get_tabledef('list_hash_2');
|
||||
SUBPARTITION p_hash_4_1_col_3_col_1_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_3_2_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_3_1_col_3_col_1_idx +
|
||||
SUBPARTITION p_list_5_subpartdefault1_col_3_col_1_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_list_2_subpartdefault1_col_3_col_1_idx +
|
||||
SUBPARTITION p_hash_6_5_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_4_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_3_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_2_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_6_1_col_3_col_1_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_1_3_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_1_2_col_3_col_1_idx, +
|
||||
SUBPARTITION p_hash_1_1_col_3_col_1_idx +
|
||||
SUBPARTITION p_list_7_subpartdefault1_col_3_col_1_idx +
|
||||
) +
|
||||
) TABLESPACE pg_default; +
|
||||
CREATE UNIQUE INDEX list_hash_2_idx1 ON list_hash_2 USING btree (col_2, col_3, col_4) LOCAL(+
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_list_7_subpartdefault1_col_2_col_3_col_4_idx +
|
||||
SUBPARTITION p_hash_1_3_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_1_2_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_1_1_col_2_col_3_col_4_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_6_5_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_4_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_3_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_2_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_1_col_2_col_3_col_4_idx +
|
||||
SUBPARTITION p_list_2_subpartdefault1_col_2_col_3_col_4_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_list_5_subpartdefault1_col_2_col_3_col_4_idx +
|
||||
SUBPARTITION p_hash_3_2_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_3_1_col_2_col_3_col_4_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_4_5_col_2_col_3_col_4_idx, +
|
||||
@ -559,16 +558,17 @@ select * from pg_get_tabledef('list_hash_2');
|
||||
SUBPARTITION p_hash_4_1_col_2_col_3_col_4_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_3_2_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_3_1_col_2_col_3_col_4_idx +
|
||||
SUBPARTITION p_list_5_subpartdefault1_col_2_col_3_col_4_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_list_2_subpartdefault1_col_2_col_3_col_4_idx +
|
||||
SUBPARTITION p_hash_6_5_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_4_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_3_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_2_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_6_1_col_2_col_3_col_4_idx +
|
||||
), +
|
||||
PARTITION partition_name( +
|
||||
SUBPARTITION p_hash_1_3_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_1_2_col_2_col_3_col_4_idx, +
|
||||
SUBPARTITION p_hash_1_1_col_2_col_3_col_4_idx +
|
||||
SUBPARTITION p_list_7_subpartdefault1_col_2_col_3_col_4_idx +
|
||||
) +
|
||||
) TABLESPACE pg_default; +
|
||||
ALTER TABLE list_hash_2 ADD CONSTRAINT list_hash_2_col_3_tableoid_key UNIQUE (col_3); +
|
||||
|
@ -35,12 +35,12 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table list_list;
|
||||
@ -73,12 +73,12 @@ insert into list_hash values('201903', '6', '1', 1);
|
||||
select * from list_hash;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201903 | 6 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 3 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201903 | 6 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table list_hash;
|
||||
@ -112,11 +112,11 @@ ERROR: inserted partition key does not map to any table partition
|
||||
select * from list_range;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 3 | 1 | 1
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
(5 rows)
|
||||
|
||||
drop table list_range;
|
||||
@ -149,12 +149,12 @@ insert into range_list values('201903', '2', '1', 1);
|
||||
select * from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table range_list;
|
||||
@ -263,12 +263,12 @@ insert into hash_list values('201903', '2', '1', 1);
|
||||
select * from hash_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 2 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table hash_list;
|
||||
@ -995,17 +995,17 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
drop table list_list;
|
||||
|
@ -643,14 +643,14 @@ explain (costs off) select * from list_range_02 where col_2 in
|
||||
-> Partitioned Index Scan using index_01 on list_range_02
|
||||
Index Cond: ((col_2 = ANY ('{100,200,300}'::integer[])) AND (col_2 > 10) AND (col_2 < 100))
|
||||
Filter: ((col_1 + col_2) = 50)
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
-> Materialize
|
||||
-> Partition Iterator
|
||||
Iterations: 1, Sub Iterations: 1
|
||||
-> Partitioned Seq Scan on list_range_02
|
||||
Filter: ((col_1 > 10) AND (col_1 < 100) AND (col_1 = ANY ('{100,200,300}'::integer[])))
|
||||
Selected Partitions: 6
|
||||
Selected Partitions: 2
|
||||
Selected Subpartitions: ALL
|
||||
(16 rows)
|
||||
|
||||
@ -677,8 +677,8 @@ explain (format yaml, costs off) select * from list_range_02 where col_2 in
|
||||
Alias: "list_range_02" +
|
||||
Index Cond: "((col_2 = ANY ('{100,200,300}'::integer[])) AND (col_2 > 10) AND (col_2 < 100))"+
|
||||
Filter: "((col_1 + col_2) = 50)" +
|
||||
Selected Partitions: "1,3,5..6" +
|
||||
Selected Subpartitions: "1:1, 3:1, 5:1, 6:1" +
|
||||
Selected Partitions: "2..3,5,7" +
|
||||
Selected Subpartitions: "2:1, 3:1, 5:1, 7:1" +
|
||||
- Node Type: "Materialize" +
|
||||
Parent Relationship: "Inner" +
|
||||
Plans: +
|
||||
@ -692,7 +692,7 @@ explain (format yaml, costs off) select * from list_range_02 where col_2 in
|
||||
Relation Name: "list_range_02" +
|
||||
Alias: "list_range_02" +
|
||||
Filter: "((col_1 > 10) AND (col_1 < 100) AND (col_1 = ANY ('{100,200,300}'::integer[])))"+
|
||||
Selected Partitions: "6" +
|
||||
Selected Partitions: "2" +
|
||||
Selected Subpartitions: "ALL"
|
||||
(1 row)
|
||||
|
||||
@ -723,8 +723,8 @@ explain (format json, costs off) select * from list_range_02 where col_2 in
|
||||
"Alias": "list_range_02", +
|
||||
"Index Cond": "((col_2 = ANY ('{100,200,300}'::integer[])) AND (col_2 > 10) AND (col_2 < 100))",+
|
||||
"Filter": "((col_1 + col_2) = 50)", +
|
||||
"Selected Partitions": "1,3,5..6", +
|
||||
"Selected Subpartitions": "1:1, 3:1, 5:1, 6:1" +
|
||||
"Selected Partitions": "2..3,5,7", +
|
||||
"Selected Subpartitions": "2:1, 3:1, 5:1, 7:1" +
|
||||
} +
|
||||
] +
|
||||
}, +
|
||||
@ -744,7 +744,7 @@ explain (format json, costs off) select * from list_range_02 where col_2 in
|
||||
"Relation Name": "list_range_02", +
|
||||
"Alias": "list_range_02", +
|
||||
"Filter": "((col_1 > 10) AND (col_1 < 100) AND (col_1 = ANY ('{100,200,300}'::integer[])))",+
|
||||
"Selected Partitions": "6", +
|
||||
"Selected Partitions": "2", +
|
||||
"Selected Subpartitions": "ALL" +
|
||||
} +
|
||||
] +
|
||||
|
@ -451,12 +451,12 @@ create view view_temp as select * from range_list;
|
||||
select * from view_temp;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
--error
|
||||
@ -1424,12 +1424,12 @@ INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 1000
|
||||
-> Partitioned Bitmap Heap Scan on subpartition_select.list_range_02
|
||||
Output: col_1, col_2, col_3, col_4
|
||||
Recheck Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000))
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
-> Partitioned Bitmap Index Scan on index_01
|
||||
Index Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000))
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
(15 rows)
|
||||
|
||||
drop index index_01;
|
||||
|
@ -95,9 +95,9 @@ select * from list_list subpartition (p_201901_c) order by 1,2,3,4;
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from list_list subpartition (p_201902_a) order by 1,2,3,4;
|
||||
|
@ -33,20 +33,20 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201901;
|
||||
@ -58,9 +58,9 @@ select * from list_list partition (p_201901);
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201902;
|
||||
|
@ -414,18 +414,18 @@ insert into t_pri_key_update_partition values (1, 1), (10, 10), (100, 100);
|
||||
select * from t_pri_key_update_partition;
|
||||
c1 | c2
|
||||
-----+-----
|
||||
100 | 100
|
||||
10 | 10
|
||||
1 | 1
|
||||
10 | 10
|
||||
100 | 100
|
||||
(3 rows)
|
||||
|
||||
update /*+ ignore_error */ t_pri_key_update_partition set c2 = 500 where c1 = 10;
|
||||
select * from t_pri_key_update_partition;
|
||||
c1 | c2
|
||||
-----+-----
|
||||
10 | 500
|
||||
100 | 100
|
||||
1 | 1
|
||||
100 | 100
|
||||
10 | 500
|
||||
(3 rows)
|
||||
|
||||
-- test for column orientation table: not supported
|
||||
|
@ -620,18 +620,18 @@ delete from t_p_mutil_t1 a partition(p_201901_a, p_201901_b),t_p_mutil_t2 b part
|
||||
select * from t_p_mutil_t1;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from t_p_mutil_t2;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(4 rows)
|
||||
|
||||
rollback;
|
||||
|
@ -701,23 +701,23 @@ update t_p_mutil_t1 a,t_p_mutil_t2 b set a.user_no=3,b.user_no=4 where a.user_no
|
||||
select * from t_p_mutil_t1;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 3 | 1
|
||||
201903 | 2 | 3 | 1
|
||||
201903 | 1 | 3 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201902 | 2 | 3 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201903 | 1 | 3 | 1
|
||||
201903 | 2 | 3 | 1
|
||||
201903 | 2 | 3 | 1
|
||||
(6 rows)
|
||||
|
||||
select * from t_p_mutil_t2;
|
||||
month_code | dept_code | user_no | sales_amt | c1
|
||||
------------+-----------+---------+-----------+----
|
||||
201903 | 2 | 4 | 1 | 2
|
||||
201903 | 2 | 4 | 1 | 2
|
||||
201903 | 1 | 4 | 1 | 2
|
||||
201902 | 1 | 4 | 1 | 2
|
||||
201902 | 1 | 4 | 1 | 2
|
||||
201902 | 2 | 4 | 1 | 2
|
||||
201902 | 1 | 4 | 1 | 2
|
||||
201902 | 1 | 4 | 1 | 2
|
||||
201903 | 1 | 4 | 1 | 2
|
||||
201903 | 2 | 4 | 1 | 2
|
||||
201903 | 2 | 4 | 1 | 2
|
||||
(6 rows)
|
||||
|
||||
rollback;
|
||||
|
@ -57,9 +57,9 @@ insert into range_list values('201903', '2', '1', 1);
|
||||
select * from range_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from range_list subpartition (p_201901_a);
|
||||
@ -72,9 +72,9 @@ select * from range_list subpartition (p_201901_a);
|
||||
select * from range_list partition for ('201902');
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from range_list subpartition for ('201902','1');
|
||||
@ -257,60 +257,60 @@ insert into range_list values('201903', '2', '1', 1);
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
update range_list partition (p_201901) set user_no = '2';
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 2 | 1
|
||||
201902 | 1 | 2 | 1
|
||||
201902 | 2 | 2 | 1
|
||||
201902 | 1 | 2 | 1
|
||||
201902 | 1 | 2 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
update range_list subpartition (p_201901_a) set user_no = '3';
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 3 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201902 | 2 | 2 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201902 | 1 | 3 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
update range_list partition for ('201902') set user_no = '4';
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 4 | 1
|
||||
201902 | 1 | 4 | 1
|
||||
201902 | 2 | 4 | 1
|
||||
201902 | 1 | 4 | 1
|
||||
201902 | 1 | 4 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
update range_list subpartition for ('201902','2') set user_no = '5';
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 4 | 1
|
||||
201902 | 1 | 4 | 1
|
||||
201902 | 2 | 5 | 1
|
||||
201902 | 1 | 4 | 1
|
||||
201902 | 1 | 4 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table range_list;
|
||||
@ -372,21 +372,21 @@ insert into range_list values('201903', '2', '1', 1);
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
delete from range_list partition (p_201901);
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
delete from range_list partition for ('201903');
|
||||
@ -404,12 +404,12 @@ insert into range_list values('201903', '2', '1', 1);
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
delete from range_list subpartition (p_201901_a);
|
||||
@ -417,9 +417,9 @@ select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(4 rows)
|
||||
|
||||
delete from range_list subpartition for ('201903','2');
|
||||
@ -959,9 +959,9 @@ WHEN NOT MATCHED THEN
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 2 | 1 | 2
|
||||
201901 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 2
|
||||
(3 rows)
|
||||
|
||||
select *from newrange_list;
|
||||
@ -988,9 +988,9 @@ WHEN NOT MATCHED THEN
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 2 | 1 | 2
|
||||
201901 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 2
|
||||
(3 rows)
|
||||
|
||||
select *from newrange_list;
|
||||
@ -1019,8 +1019,8 @@ DETAIL: new tuple does not map to any table partition
|
||||
select *from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 2 | 1 | 2
|
||||
201901 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 2
|
||||
(2 rows)
|
||||
|
||||
select *from newrange_list;
|
||||
|
@ -1585,7 +1585,7 @@ explain(costs off, verbose on) select min(a) from test_list_lt where a = 2000;
|
||||
-> Partitioned Index Only Scan using idx_list_a on partition_minmax.test_list_lt
|
||||
Output: partition_minmax.test_list_lt.a
|
||||
Index Cond: ((partition_minmax.test_list_lt.a IS NOT NULL) AND (partition_minmax.test_list_lt.a = 2000))
|
||||
Selected Partitions: 3
|
||||
Selected Partitions: 1
|
||||
(9 rows)
|
||||
|
||||
select min(a) from test_list_lt where a = 2000;
|
||||
|
@ -35,12 +35,12 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table list_list;
|
||||
@ -73,12 +73,12 @@ insert into list_hash values('201903', '6', '1', 1);
|
||||
select * from list_hash;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201903 | 6 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 3 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201903 | 6 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table list_hash;
|
||||
@ -112,11 +112,11 @@ ERROR: inserted partition key does not map to any table partition
|
||||
select * from list_range;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 3 | 1 | 1
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
(5 rows)
|
||||
|
||||
drop table list_range;
|
||||
@ -149,12 +149,12 @@ insert into range_list values('201903', '2', '1', 1);
|
||||
select * from range_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table range_list;
|
||||
@ -263,12 +263,12 @@ insert into hash_list values('201903', '2', '1', 1);
|
||||
select * from hash_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 2 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
drop table hash_list;
|
||||
@ -995,17 +995,17 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
drop table list_list;
|
||||
|
@ -644,14 +644,14 @@ explain (costs off) select * from list_range_02 where col_2 in
|
||||
-> Partitioned Index Scan using index_01 on list_range_02
|
||||
Index Cond: ((col_2 = ANY ('{100,200,300}'::integer[])) AND (col_2 > 10) AND (col_2 < 100))
|
||||
Filter: ((col_1 + col_2) = 50)
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
-> Materialize
|
||||
-> Partition Iterator
|
||||
Iterations: 1, Sub Iterations: 1
|
||||
-> Partitioned Seq Scan on list_range_02
|
||||
Filter: ((col_1 > 10) AND (col_1 < 100) AND (col_1 = ANY ('{100,200,300}'::integer[])))
|
||||
Selected Partitions: 6
|
||||
Selected Partitions: 2
|
||||
Selected Subpartitions: ALL
|
||||
(16 rows)
|
||||
|
||||
|
@ -346,12 +346,12 @@ create view view_temp as select * from range_list;
|
||||
select * from view_temp;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
--error
|
||||
@ -1166,12 +1166,12 @@ INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 1000
|
||||
-> Partitioned Bitmap Heap Scan on segment_subpartition_select.list_range_02
|
||||
Output: col_1, col_2, col_3, col_4
|
||||
Recheck Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000))
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
-> Partitioned Bitmap Index Scan on index_01
|
||||
Index Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000))
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
(15 rows)
|
||||
|
||||
drop index index_01;
|
||||
|
@ -81,9 +81,9 @@ select * from list_list subpartition (p_201901_c) order by 1,2,3,4;
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from list_list subpartition (p_201902_a) order by 1,2,3,4;
|
||||
|
@ -33,20 +33,20 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201901;
|
||||
@ -58,9 +58,9 @@ select * from list_list partition (p_201901);
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201902;
|
||||
|
@ -2683,7 +2683,7 @@ explain(costs off, verbose on) select *from test_list_lt where a = 2000 and b =
|
||||
Output: a, b, c
|
||||
Index Cond: (test_list_lt.b = 1)
|
||||
Filter: (test_list_lt.a = 2000)
|
||||
Selected Partitions: 3
|
||||
Selected Partitions: 1
|
||||
(6 rows)
|
||||
|
||||
explain(costs off, verbose on) select *from test_list_lt where a = 5000 and b = 1 order by c;
|
||||
|
@ -33,20 +33,20 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201901;
|
||||
@ -58,9 +58,9 @@ select * from list_list partition (p_201901);
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201902;
|
||||
|
@ -352,60 +352,6 @@ select * from check_truncate_results where tablename = 'tg_list';
|
||||
select * from tg_list;
|
||||
a | b
|
||||
---+---
|
||||
2 | 0
|
||||
2 | 1
|
||||
2 | 2
|
||||
2 | 3
|
||||
2 | 4
|
||||
2 | 5
|
||||
2 | 6
|
||||
2 | 7
|
||||
2 | 8
|
||||
5 | 0
|
||||
5 | 1
|
||||
5 | 2
|
||||
5 | 3
|
||||
5 | 4
|
||||
5 | 5
|
||||
5 | 6
|
||||
5 | 7
|
||||
5 | 8
|
||||
8 | 0
|
||||
8 | 1
|
||||
8 | 2
|
||||
8 | 3
|
||||
8 | 4
|
||||
8 | 5
|
||||
8 | 6
|
||||
8 | 7
|
||||
8 | 8
|
||||
1 | 0
|
||||
1 | 1
|
||||
1 | 2
|
||||
1 | 3
|
||||
1 | 4
|
||||
1 | 5
|
||||
1 | 6
|
||||
1 | 7
|
||||
1 | 8
|
||||
4 | 0
|
||||
4 | 1
|
||||
4 | 2
|
||||
4 | 3
|
||||
4 | 4
|
||||
4 | 5
|
||||
4 | 6
|
||||
4 | 7
|
||||
4 | 8
|
||||
7 | 0
|
||||
7 | 1
|
||||
7 | 2
|
||||
7 | 3
|
||||
7 | 4
|
||||
7 | 5
|
||||
7 | 6
|
||||
7 | 7
|
||||
7 | 8
|
||||
0 | 0
|
||||
0 | 1
|
||||
0 | 2
|
||||
@ -433,6 +379,60 @@ select * from tg_list;
|
||||
6 | 6
|
||||
6 | 7
|
||||
6 | 8
|
||||
1 | 0
|
||||
1 | 1
|
||||
1 | 2
|
||||
1 | 3
|
||||
1 | 4
|
||||
1 | 5
|
||||
1 | 6
|
||||
1 | 7
|
||||
1 | 8
|
||||
4 | 0
|
||||
4 | 1
|
||||
4 | 2
|
||||
4 | 3
|
||||
4 | 4
|
||||
4 | 5
|
||||
4 | 6
|
||||
4 | 7
|
||||
4 | 8
|
||||
7 | 0
|
||||
7 | 1
|
||||
7 | 2
|
||||
7 | 3
|
||||
7 | 4
|
||||
7 | 5
|
||||
7 | 6
|
||||
7 | 7
|
||||
7 | 8
|
||||
2 | 0
|
||||
2 | 1
|
||||
2 | 2
|
||||
2 | 3
|
||||
2 | 4
|
||||
2 | 5
|
||||
2 | 6
|
||||
2 | 7
|
||||
2 | 8
|
||||
5 | 0
|
||||
5 | 1
|
||||
5 | 2
|
||||
5 | 3
|
||||
5 | 4
|
||||
5 | 5
|
||||
5 | 6
|
||||
5 | 7
|
||||
5 | 8
|
||||
8 | 0
|
||||
8 | 1
|
||||
8 | 2
|
||||
8 | 3
|
||||
8 | 4
|
||||
8 | 5
|
||||
8 | 6
|
||||
8 | 7
|
||||
8 | 8
|
||||
(81 rows)
|
||||
|
||||
explain(costs off) select /*+ indexscan(tg_list i_tg_list_global_b) */ * from tg_list where b < 9;
|
||||
@ -541,60 +541,6 @@ explain(costs off) select /*+ indexscan(tg_list i_tg_list_local_a) */ * from tg_
|
||||
select /*+ indexscan(tg_list i_tg_list_local_a) */ * from tg_list where a < 9;
|
||||
a | b
|
||||
---+---
|
||||
2 | 8
|
||||
2 | 7
|
||||
2 | 6
|
||||
2 | 5
|
||||
2 | 4
|
||||
2 | 3
|
||||
2 | 2
|
||||
2 | 1
|
||||
2 | 0
|
||||
5 | 8
|
||||
5 | 7
|
||||
5 | 6
|
||||
5 | 5
|
||||
5 | 4
|
||||
5 | 3
|
||||
5 | 2
|
||||
5 | 1
|
||||
5 | 0
|
||||
8 | 8
|
||||
8 | 7
|
||||
8 | 6
|
||||
8 | 5
|
||||
8 | 4
|
||||
8 | 3
|
||||
8 | 2
|
||||
8 | 1
|
||||
8 | 0
|
||||
1 | 8
|
||||
1 | 7
|
||||
1 | 6
|
||||
1 | 5
|
||||
1 | 4
|
||||
1 | 3
|
||||
1 | 2
|
||||
1 | 1
|
||||
1 | 0
|
||||
4 | 8
|
||||
4 | 7
|
||||
4 | 6
|
||||
4 | 5
|
||||
4 | 4
|
||||
4 | 3
|
||||
4 | 2
|
||||
4 | 1
|
||||
4 | 0
|
||||
7 | 8
|
||||
7 | 7
|
||||
7 | 6
|
||||
7 | 5
|
||||
7 | 4
|
||||
7 | 3
|
||||
7 | 2
|
||||
7 | 1
|
||||
7 | 0
|
||||
0 | 8
|
||||
0 | 7
|
||||
0 | 6
|
||||
@ -622,6 +568,60 @@ select /*+ indexscan(tg_list i_tg_list_local_a) */ * from tg_list where a < 9;
|
||||
6 | 2
|
||||
6 | 1
|
||||
6 | 0
|
||||
1 | 8
|
||||
1 | 7
|
||||
1 | 6
|
||||
1 | 5
|
||||
1 | 4
|
||||
1 | 3
|
||||
1 | 2
|
||||
1 | 1
|
||||
1 | 0
|
||||
4 | 8
|
||||
4 | 7
|
||||
4 | 6
|
||||
4 | 5
|
||||
4 | 4
|
||||
4 | 3
|
||||
4 | 2
|
||||
4 | 1
|
||||
4 | 0
|
||||
7 | 8
|
||||
7 | 7
|
||||
7 | 6
|
||||
7 | 5
|
||||
7 | 4
|
||||
7 | 3
|
||||
7 | 2
|
||||
7 | 1
|
||||
7 | 0
|
||||
2 | 8
|
||||
2 | 7
|
||||
2 | 6
|
||||
2 | 5
|
||||
2 | 4
|
||||
2 | 3
|
||||
2 | 2
|
||||
2 | 1
|
||||
2 | 0
|
||||
5 | 8
|
||||
5 | 7
|
||||
5 | 6
|
||||
5 | 5
|
||||
5 | 4
|
||||
5 | 3
|
||||
5 | 2
|
||||
5 | 1
|
||||
5 | 0
|
||||
8 | 8
|
||||
8 | 7
|
||||
8 | 6
|
||||
8 | 5
|
||||
8 | 4
|
||||
8 | 3
|
||||
8 | 2
|
||||
8 | 1
|
||||
8 | 0
|
||||
(81 rows)
|
||||
|
||||
drop table tg_list;
|
||||
|
@ -34,11 +34,11 @@ insert into list_list values('201903', '1', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(5 rows)
|
||||
|
||||
drop table list_list;
|
||||
@ -69,10 +69,10 @@ insert into list_hash values('201903', '5', '1', 1);
|
||||
select * from list_hash;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
(4 rows)
|
||||
|
||||
drop table list_hash;
|
||||
@ -105,10 +105,10 @@ ERROR: inserted partition key does not map to any table partition
|
||||
select * from list_range;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201903 | 4 | 1 | 1
|
||||
201903 | 5 | 1 | 1
|
||||
(4 rows)
|
||||
|
||||
drop table list_range;
|
||||
@ -140,11 +140,11 @@ insert into hash_list values('201903', '1', '1', 1);
|
||||
select * from hash_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 2 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
201901 | 1 | 1 | 1
|
||||
(5 rows)
|
||||
|
||||
drop table hash_list;
|
||||
@ -866,16 +866,16 @@ insert into list_list values('201903', '1', '1', 1);
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(2 rows)
|
||||
|
||||
drop table list_list;
|
||||
|
@ -640,14 +640,14 @@ explain (costs off) select * from list_range_02 where col_2 in
|
||||
-> Partitioned Index Scan using index_01 on list_range_02
|
||||
Index Cond: ((col_2 = ANY ('{100,200,300}'::integer[])) AND (col_2 > 10) AND (col_2 < 100))
|
||||
Filter: ((col_1 + col_2) = 50)
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
-> Materialize
|
||||
-> Partition Iterator
|
||||
Iterations: 1, Sub Iterations: 1
|
||||
-> Partitioned Seq Scan on list_range_02
|
||||
Filter: ((col_1 > 10) AND (col_1 < 100) AND (col_1 = ANY ('{100,200,300}'::integer[])))
|
||||
Selected Partitions: 6
|
||||
Selected Partitions: 2
|
||||
Selected Subpartitions: ALL
|
||||
(16 rows)
|
||||
|
||||
|
@ -346,12 +346,12 @@ create view view_temp as select * from range_list;
|
||||
select * from view_temp;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
--error
|
||||
@ -1166,12 +1166,12 @@ INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 1000
|
||||
-> Partitioned Bitmap Heap Scan on ustore_subpartition_select.list_range_02
|
||||
Output: col_1, col_2, col_3, col_4
|
||||
Recheck Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000))
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
-> Partitioned Bitmap Index Scan on index_01
|
||||
Index Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000))
|
||||
Selected Partitions: 1,3,5..6
|
||||
Selected Subpartitions: 1:1, 3:1, 5:1, 6:1
|
||||
Selected Partitions: 2..3,5,7
|
||||
Selected Subpartitions: 2:1, 3:1, 5:1, 7:1
|
||||
(15 rows)
|
||||
|
||||
drop index index_01;
|
||||
|
@ -81,9 +81,9 @@ select * from list_list subpartition (p_201901_c) order by 1,2,3,4;
|
||||
select * from list_list partition (p_201901);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
select * from list_list subpartition (p_201902_a) order by 1,2,3,4;
|
||||
|
@ -33,20 +33,20 @@ insert into list_list values('201903', '2', '1', 1);
|
||||
select * from list_list;
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 2 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201902 | 1 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(6 rows)
|
||||
|
||||
select * from list_list partition (p_201902);
|
||||
month_code | dept_code | user_no | sales_amt
|
||||
------------+-----------+---------+-----------
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 1 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
201903 | 2 | 1 | 1
|
||||
(3 rows)
|
||||
|
||||
alter table list_list truncate partition p_201902;
|
||||
|
@ -110,10 +110,10 @@ explain (costs off) select * from list_list;
|
||||
select * from list_list;
|
||||
col_1 | col_2 | col_3 | col_4
|
||||
-------+-------+-------+-------
|
||||
11 | 2 | cc | 4
|
||||
19 | 8 | dd | 16
|
||||
1 | 1 | aa | 2
|
||||
5 | 5 | bb | 10
|
||||
11 | 2 | cc | 4
|
||||
19 | 8 | dd | 16
|
||||
(4 rows)
|
||||
|
||||
drop table if exists list_list_02;
|
||||
|
@ -2195,23 +2195,23 @@ insert into partition_list values(40,'forty-three',43);
|
||||
select rownum,* from partition_list;
|
||||
rownum | id | name | age
|
||||
--------+----+--------------+-----
|
||||
1 | 40 | forty | 40
|
||||
2 | 40 | forty-three | 43
|
||||
3 | 30 | thirty | 30
|
||||
4 | 30 | Thirty-three | 33
|
||||
5 | 20 | twenty | 20
|
||||
6 | 20 | twenty-three | 23
|
||||
7 | 10 | ten | 10
|
||||
8 | 10 | thirteen | 13
|
||||
1 | 10 | ten | 10
|
||||
2 | 10 | thirteen | 13
|
||||
3 | 20 | twenty | 20
|
||||
4 | 20 | twenty-three | 23
|
||||
5 | 30 | thirty | 30
|
||||
6 | 30 | Thirty-three | 33
|
||||
7 | 40 | forty | 40
|
||||
8 | 40 | forty-three | 43
|
||||
(8 rows)
|
||||
|
||||
select * from partition_list where rownum < 5;
|
||||
id | name | age
|
||||
----+--------------+-----
|
||||
40 | forty | 40
|
||||
40 | forty-three | 43
|
||||
30 | thirty | 30
|
||||
30 | Thirty-three | 33
|
||||
10 | ten | 10
|
||||
10 | thirteen | 13
|
||||
20 | twenty | 20
|
||||
20 | twenty-three | 23
|
||||
(4 rows)
|
||||
|
||||
drop table partition_list;
|
||||
|
Reference in New Issue
Block a user