|
| 1 | +-- test cluster_columns |
| 2 | +set pax_max_tuples_per_file to 131072; |
| 3 | +drop table if EXISTS t_zorder_cluster; |
| 4 | +create table t_zorder_cluster(c1 int, c2 int) using pax with(minmax_columns='c1,c2'); |
| 5 | +\d+ t_zorder_cluster; |
| 6 | + Table "public.t_zorder_cluster" |
| 7 | + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description |
| 8 | +--------+---------+-----------+----------+---------+---------+--------------+------------- |
| 9 | + c1 | integer | | | | plain | | |
| 10 | + c2 | integer | | | | plain | | |
| 11 | +Distributed by: (c1) |
| 12 | +Options: minmax_columns=c1,c2 |
| 13 | + |
| 14 | +insert into t_zorder_cluster select i,i from generate_series(1,100000) i; |
| 15 | +insert into t_zorder_cluster select i,i from generate_series(1,100000) i; |
| 16 | +insert into t_zorder_cluster select i,i from generate_series(1,100000) i; |
| 17 | +insert into t_zorder_cluster select i,i from generate_series(1,100000) i; |
| 18 | +insert into t_zorder_cluster select i,i from generate_series(1,100000) i; |
| 19 | +select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_zorder_cluster'); |
| 20 | + ptblockname | ptstatistics | ptisclustered |
| 21 | +-------------+-------------------------------------------------------------------------------------------------+--------------- |
| 22 | + 0 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 23 | + 1 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 24 | + 2 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 25 | + 3 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 26 | + 4 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 27 | + 0 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 28 | + 1 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 29 | + 2 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 30 | + 3 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 31 | + 4 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 32 | + 0 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 33 | + 1 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 34 | + 2 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 35 | + 3 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 36 | + 4 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 37 | +(15 rows) |
| 38 | + |
| 39 | +-- error, becuase no cluster index or cluster_columns is defined |
| 40 | +cluster t_zorder_cluster; |
| 41 | +ERROR: there is no previously clustered index or cluster_columns reloptions for table "t_zorder_cluster" |
| 42 | +alter table t_zorder_cluster set(cluster_columns='c1,c2'); |
| 43 | +\d+ t_zorder_cluster; |
| 44 | + Table "public.t_zorder_cluster" |
| 45 | + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description |
| 46 | +--------+---------+-----------+----------+---------+---------+--------------+------------- |
| 47 | + c1 | integer | | | | plain | | |
| 48 | + c2 | integer | | | | plain | | |
| 49 | +Distributed by: (c1) |
| 50 | +Options: minmax_columns=c1,c2, cluster_columns=c1,c2 |
| 51 | + |
| 52 | +-- success |
| 53 | +cluster t_zorder_cluster; |
| 54 | +select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_zorder_cluster'); |
| 55 | + ptblockname | ptstatistics | ptisclustered |
| 56 | +-------------+---------------------------------------------------------------------------------------------------------+--------------- |
| 57 | + 5 | [(false,false),(131072),(1,78633),(5126644321)],[(false,false),(131072),(1,78633),(5126644321)] | t |
| 58 | + 6 | [(false,false),(35563),(78633,99996),(3178950384)],[(false,false),(35563),(78633,99996),(3178950384)] | t |
| 59 | + 5 | [(false,false),(131072),(2,78230),(5147801190)],[(false,false),(131072),(2,78230),(5147801190)] | t |
| 60 | + 6 | [(false,false),(36238),(78230,99999),(3226202455)],[(false,false),(36238),(78230,99999),(3226202455)] | t |
| 61 | + 5 | [(false,false),(131072),(5,79072),(5187913809)],[(false,false),(131072),(5,79072),(5187913809)] | t |
| 62 | + 6 | [(false,false),(34983),(79072,100000),(3132737841)],[(false,false),(34983),(79072,100000),(3132737841)] | t |
| 63 | +(6 rows) |
| 64 | + |
| 65 | +drop table t_zorder_cluster; |
| 66 | +-- test cluster index |
| 67 | +set pax_max_tuples_per_file to 131072; |
| 68 | +drop table if EXISTS t_index_cluster; |
| 69 | +NOTICE: table "t_index_cluster" does not exist, skipping |
| 70 | +create table t_index_cluster(c1 int, c2 int) using pax with(minmax_columns='c1,c2'); |
| 71 | +\d+ t_index_cluster; |
| 72 | + Table "public.t_index_cluster" |
| 73 | + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description |
| 74 | +--------+---------+-----------+----------+---------+---------+--------------+------------- |
| 75 | + c1 | integer | | | | plain | | |
| 76 | + c2 | integer | | | | plain | | |
| 77 | +Distributed by: (c1) |
| 78 | +Options: minmax_columns=c1,c2 |
| 79 | + |
| 80 | +insert into t_index_cluster select i,i from generate_series(1,100000) i; |
| 81 | +insert into t_index_cluster select i,i from generate_series(1,100000) i; |
| 82 | +insert into t_index_cluster select i,i from generate_series(1,100000) i; |
| 83 | +insert into t_index_cluster select i,i from generate_series(1,100000) i; |
| 84 | +insert into t_index_cluster select i,i from generate_series(1,100000) i; |
| 85 | +select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_index_cluster'); |
| 86 | + ptblockname | ptstatistics | ptisclustered |
| 87 | +-------------+-------------------------------------------------------------------------------------------------+--------------- |
| 88 | + 0 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 89 | + 1 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 90 | + 2 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 91 | + 3 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 92 | + 4 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f |
| 93 | + 0 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 94 | + 1 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 95 | + 2 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 96 | + 3 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 97 | + 4 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f |
| 98 | + 0 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 99 | + 1 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 100 | + 2 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 101 | + 3 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 102 | + 4 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f |
| 103 | +(15 rows) |
| 104 | + |
| 105 | +-- error, becuase no cluster index or cluster_columns is defined |
| 106 | +cluster t_index_cluster; |
| 107 | +ERROR: there is no previously clustered index or cluster_columns reloptions for table "t_index_cluster" |
| 108 | +create index idx_t_index_cluster on t_index_cluster(c1); |
| 109 | +\d+ t_index_cluster; |
| 110 | + Table "public.t_index_cluster" |
| 111 | + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description |
| 112 | +--------+---------+-----------+----------+---------+---------+--------------+------------- |
| 113 | + c1 | integer | | | | plain | | |
| 114 | + c2 | integer | | | | plain | | |
| 115 | +Indexes: |
| 116 | + "idx_t_index_cluster" btree (c1) |
| 117 | +Distributed by: (c1) |
| 118 | +Options: minmax_columns=c1,c2 |
| 119 | + |
| 120 | +-- success |
| 121 | +cluster t_index_cluster using idx_t_index_cluster; |
| 122 | +select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_index_cluster'); |
| 123 | + ptblockname | ptstatistics | ptisclustered |
| 124 | +-------------+---------------------------------------------------------------------------------------------------------+--------------- |
| 125 | + 0 | [(false,false),(131072),(2,78230),(5147801190)],[(false,false),(131072),(2,78230),(5147801190)] | t |
| 126 | + 1 | [(false,false),(36238),(78230,99999),(3226202455)],[(false,false),(36238),(78230,99999),(3226202455)] | t |
| 127 | + 0 | [(false,false),(131072),(1,78633),(5126644321)],[(false,false),(131072),(1,78633),(5126644321)] | t |
| 128 | + 1 | [(false,false),(35563),(78633,99996),(3178950384)],[(false,false),(35563),(78633,99996),(3178950384)] | t |
| 129 | + 0 | [(false,false),(131072),(5,79072),(5187913809)],[(false,false),(131072),(5,79072),(5187913809)] | t |
| 130 | + 1 | [(false,false),(34983),(79072,100000),(3132737841)],[(false,false),(34983),(79072,100000),(3132737841)] | t |
| 131 | +(6 rows) |
| 132 | + |
| 133 | +drop table t_index_cluster; |
| 134 | +-- test both cluster index and cluster columns |
| 135 | +create table t_both_zorder_and_index_cluster(c1 int, c2 int) using pax with(minmax_columns='c1,c2'); |
| 136 | +alter table t_both_zorder_and_index_cluster set(cluster_columns='c1,c2'); |
| 137 | +create index idx_t_both_zorder_and_index_cluster on t_both_zorder_and_index_cluster(c1); |
| 138 | +-- error, because zorder cluster and index cluster can not be used together |
| 139 | +cluster t_both_zorder_and_index_cluster using idx_t_both_zorder_and_index_cluster; |
| 140 | +ERROR: cannot using index to cluster table which has cluster-columns (pax_access_handle.cc:1186) |
| 141 | +-- success |
| 142 | +cluster t_both_zorder_and_index_cluster; |
| 143 | +alter table t_both_zorder_and_index_cluster set(cluster_columns=''); |
| 144 | +-- error, because zorder cluster reloptions has been deleted |
| 145 | +cluster t_both_zorder_and_index_cluster; |
| 146 | +ERROR: there is no previously clustered index or cluster_columns reloptions for table "t_both_zorder_and_index_cluster" |
| 147 | +-- success |
| 148 | +cluster t_both_zorder_and_index_cluster using idx_t_both_zorder_and_index_cluster; |
| 149 | +-- error |
| 150 | +alter table t_both_zorder_and_index_cluster set(cluster_columns='c1,c2'); |
| 151 | +ERROR: pax table has previously clustered index, can't set zorder cluster reloptions (pax_access_handle.cc:1308) |
| 152 | +drop index idx_t_both_zorder_and_index_cluster; |
| 153 | +-- error |
| 154 | +cluster t_both_zorder_and_index_cluster; |
| 155 | +ERROR: there is no previously clustered index or cluster_columns reloptions for table "t_both_zorder_and_index_cluster" |
| 156 | +-- success |
| 157 | +alter table t_both_zorder_and_index_cluster set(cluster_columns='c1,c2'); |
| 158 | +-- success |
| 159 | +cluster t_both_zorder_and_index_cluster; |
| 160 | +-- test unsupport type |
| 161 | +create table t_zorder_unsupport_type(c1 int, c2 numeric(10,2),c3 varchar(128), c4 timestamp, c5 bpchar(64) ) using pax with(minmax_columns='c1,c2'); |
| 162 | +-- error, because numeric is unsupport type |
| 163 | +alter table t_zorder_unsupport_type set(cluster_columns='c1,c2'); |
| 164 | +ERROR: the type of column c2 does not support zorder cluster (paxc_rel_options.cc:307) |
| 165 | +alter table t_zorder_unsupport_type set(cluster_columns='c1,c3'); |
| 166 | +-- error, because timestamp is unsupport type |
| 167 | +alter table t_zorder_unsupport_type set(cluster_columns='c1,c4'); |
| 168 | +ERROR: the type of column c4 does not support zorder cluster (paxc_rel_options.cc:307) |
| 169 | +alter table t_zorder_unsupport_type set(cluster_columns='c1,c5'); |
0 commit comments