Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.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
Performance 如何在选择时间戳之间进行优化_Performance_Postgresql - Fatal编程技术网

Performance 如何在选择时间戳之间进行优化

Performance 如何在选择时间戳之间进行优化,performance,postgresql,Performance,Postgresql,我的表中有一个时间戳字段,希望选择 SELECT * FROM table WHERE time BETWEEN '2014-12-06' AND '2014-12-09' 我已经创建了这个索引 CREATE INDEX myindex ON table (time); 该表有1.014.890个条目 查询在16秒内返回282.000条记录 说明 "Bitmap Heap Scan on trackdatagps (cost=6126.29..25884.11 rows=288188 wi

我的表中有一个时间戳字段,希望选择

SELECT * FROM table
WHERE time BETWEEN '2014-12-06' AND '2014-12-09'
我已经创建了这个索引

CREATE INDEX myindex ON table (time);
该表有1.014.890个条目

查询在16秒内返回282.000条记录

说明

"Bitmap Heap Scan on trackdatagps  (cost=6126.29..25884.11 rows=288188 width=79)"
"  Recheck Cond: (("time" >= '2014-12-06 00:00:00'::timestamp without time zone) 
                  AND 
                  ("time" <= '2014-12-09 00:00:00'::timestamp without time zone))"
"  ->  Bitmap Index Scan on table  (cost=0.00..6054.24 rows=288188 width=0)"
"        Index Cond: (("time" >= '2014-12-06 00:00:00'::timestamp without time zone) 
                      AND 
                      ("time" <= '2014-12-09 00:00:00'::timestamp without time zone))"
“trackdatagps上的位图堆扫描(成本=6126.29..25884.11行=288188宽度=79)”
“复查条件:((“时间”>=“2014-12-06 00:00:00”::无时区的时间戳)
及
(“时间”位图索引扫描表(成本=0.00..6054.24行=288188宽度=0)
“索引条件:((“时间”>='2014-12-06 00:00:00'::不带时区的时间戳)
及
(“时间”
这将运行缓慢(尤其是第一次),但它将组织表内容,使您使用的查询更高效


特别是如果使用较小的时间范围或较大的表。

如果只查询
count(*),持续时间是多少
也就是说,有多少时间是由于延迟将282k行传递给调用者造成的?它每秒返回17625条记录,还不错。您是否检查了EXPLAIN Analysis以查看执行查询花费了多少时间?我认为大部分时间都花在返回数据上,而不是执行查询上。
cluster table using myindex;