我试图测试PostgreSQL中不同分区模式的效率.我用一个表和不同的分区大小创建了几个数据库,然后在每个数据库中填充了数亿个记录.
现在我想测试所有这些查询并比较结果.但问题是,当我运行相同的查询时,我在一个数据库上收到了不同的实际时间.
例如,我EXPLAIN (buffers, analyze, verbose) SELECT count(*) FROM testdata WHERE dt = '2017-06-01 08:50:00'第一次执行:
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=356199.96..356199.97 rows=1 width=8) (actual time=155757.190..155757.190 rows=1 loops=1)
Output: count(*)
Buffers: shared read=290555
-> Append (cost=0.00..354506.51 rows=677381 width=0) (actual time=165.565..155583.815 rows=665275 loops=1)
Buffers: shared read=290555
-> Seq Scan on public.testdata (cost=0.00..0.00 rows=1 width=0) (actual time=0.002..0.002 rows=0 loops=1)
Filter: (testdata.dt = '2017-06-01 08:50:00'::timestamp without time zone)
-> Bitmap Heap Scan on public.testdata_2017_06_01 (cost=12682.26..354506.51 rows=677380 width=0) (actual time=165.562..155319.677 rows=665275 loops=1)
Recheck Cond: …Run Code Online (Sandbox Code Playgroud)