Greenplum 查询特定值的分区表名称

Greenplum 查询特定值的分区表名称,greenplum,Greenplum,我用带有时区的时间戳对一个表进行了分区。然后我添加了一个分区,然后在该分区上添加了一个索引。现在,Greenplum似乎只在真空分析表名之后使用该索引。否则,它使用顺序扫描 真空分析TABLENAME的缺点是需要相当长的时间。它想做一个真空分析PARTITIONTABLENAME,因为我知道上个月的每日分区已经没有变化了 问题是:如何获取特定值(如current\u timestamp)的分区表名称?换句话说:我希望访问Greenplum用来决定在哪个分区中放置新条目的函数。Greenplum中

我用带有时区的
时间戳对一个表进行了分区。然后我添加了一个分区,然后在该分区上添加了一个索引。现在,Greenplum似乎只在
真空分析表名之后使用该索引。否则,它使用顺序扫描

真空分析TABLENAME
的缺点是需要相当长的时间。它想做一个
真空分析PARTITIONTABLENAME
,因为我知道上个月的每日分区已经没有变化了


问题是:如何获取特定值(如
current\u timestamp
)的分区表名称?换句话说:我希望访问Greenplum用来决定在哪个分区中放置新条目的函数。

Greenplum中的分区与任何其他表一样处理。如果您具有psql访问权限,则应该能够使用“\d”命令在搜索路径中查看您有权访问的所有表。较大表的每个部分都将显示在该表中。除非您明确地命名分区,否则greenplum将仅根据父表名和自动递增的分区号命名分区:

gpadmin=# create table testtab (testcol varchar(10),
gpadmin(#  test_time timestamptz)
gpadmin-# distributed by (testcol)
gpadmin-#  partition by range (test_time)
gpadmin-# ( START (date '2013-10-01') INCLUSIVE
gpadmin(#   END  (date '2013-11-25') EXCLUSIVE
gpadmin(# EVERY (INTERVAL '1 week'));
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_1" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_2" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_3" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_4" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_5" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_6" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_7" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_8" for table "testtab"
CREATE TABLE
Time: 252.080 ms
gpadmin=#
要仅清空最近的分区,可以创建一个函数,返回分区号最高的表:

gpadmin=# select tablename from pg_tables
gpadmin-# where tablename like 'testtab_1_prt_%' 
gpadmin-# order by tablename desc limit 1;
    tablename    
-----------------
 testtab_1_prt_8
(1 row)

Time: 89.151 ms

然后通过真空分析

Greenplum中的分区与任何其他表一样处理。如果您具有psql访问权限,则应该能够使用“\d”命令在搜索路径中查看您有权访问的所有表。较大表的每个部分都将显示在该表中。除非您明确地命名分区,否则greenplum将仅根据父表名和自动递增的分区号命名分区:

gpadmin=# create table testtab (testcol varchar(10),
gpadmin(#  test_time timestamptz)
gpadmin-# distributed by (testcol)
gpadmin-#  partition by range (test_time)
gpadmin-# ( START (date '2013-10-01') INCLUSIVE
gpadmin(#   END  (date '2013-11-25') EXCLUSIVE
gpadmin(# EVERY (INTERVAL '1 week'));
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_1" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_2" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_3" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_4" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_5" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_6" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_7" for table "testtab"
NOTICE:  CREATE TABLE will create partition "testtab_1_prt_8" for table "testtab"
CREATE TABLE
Time: 252.080 ms
gpadmin=#
要仅清空最近的分区,可以创建一个函数,返回分区号最高的表:

gpadmin=# select tablename from pg_tables
gpadmin-# where tablename like 'testtab_1_prt_%' 
gpadmin-# order by tablename desc limit 1;
    tablename    
-----------------
 testtab_1_prt_8
(1 row)

Time: 89.151 ms
然后通过真空分析