Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database greenplum划分优化_Database_Greenplum - Fatal编程技术网

Database greenplum划分优化

Database greenplum划分优化,database,greenplum,Database,Greenplum,在greenplum上,我有一个名为fact\u table的大表,它由RANGE(day\u bucket)分区。为什么以下查询速度如此之慢: select max(day_bucket) from fact_table where day_bucket >= '2011-09-11 00:00:00' and day_bucket < '2011-12-14'. Explain命令显示它始终执行完全扫描: ->仅在mytestlist_1_prt_p20120102 mytes

在greenplum上,我有一个名为
fact\u table
的大表,它由
RANGE(day\u bucket)
分区。为什么以下查询速度如此之慢:

select max(day_bucket) from fact_table where day_bucket >= '2011-09-11 00:00:00' and day_bucket < '2011-12-14'.
Explain命令显示它始终执行完全扫描:

->仅在mytestlist_1_prt_p20120102 mytestlist上追加列扫描(成本=0.00..34.95行=1宽度=8) 过滤器:day_bucket>='2012-01-02 00:00:00'::不带时区和day_bucket的时间戳仅在mytestlist上附加列扫描\u 1\u prt\u p20120103 mytestlist(成本=0.00..39.61行=1宽度=8)
过滤器:day_bucket>='2012-01-02 00:00:00'::没有时区和day_bucket的时间戳您应该注意应用于分区的约束。 为了让优化器正确地从扫描中排除某些分区,您应该帮助他。在您的情况下,应该使用显式类型转换:(GP在计划阶段无法自动理解像“yyyy-mm-dd”这样的stings实际上是时间戳)

选择最大值(日桶)
从事实表
其中日期>='2011-09-11 00:00:00'::时间戳
和day_bucket<'2011-12-14':时间戳

表中是否有索引?每个分区平均有多少行?以后请编辑您的问题以添加更多信息。而且,我已经合并了您意外创建的额外帐户。您使用的是什么版本的GPDB?你能发布一个完整的解释计划吗? CREATE TABLE fact_table ( id character varying(25) NOT NULL, day_bucket timestamp without time zone NOT NULL, ) WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=6) DISTRIBUTED BY (user_id) PARTITION BY LIST(day_bucket) ( PARTITION p20120101 VALUES ('2012-01-01 00:00:00'::timestamp without time zone) WITH (tablename='fact_table_1_prt_p20120101', appendonly=true, orientation=column, compresstype=zlib, compresslevel=6 ), PARTITION p20120102 VALUES ('2012-01-02 00:00:00'::timestamp without time zone) WITH (tablename='fact_table_1_prt_p20120102', appendonly=true, orientation=column, compresstype=zlib, compresslevel=6 ), PARTITION p20120103 VALUES ('2012-01-03 00:00:00'::timestamp without time zone) WITH (tablename='fact_table_1_prt_p20120103', appendonly=true, orientation=column, compresstype=zlib, compresslevel=6 ), PARTITION p20120104 VALUES ('2012-01-04 00:00:00'::timestamp without time zone) WITH (tablename='fact_table_1_prt_p20120104', appendonly=true, orientation=column, compresstype=zlib, compresslevel=6 ), .....
select max(day_bucket) 
from fact_table 
where day_bucket >= '2011-09-11 00:00:00'::timestamp 
  and day_bucket <  '2011-12-14'::timestamp