为了提高性能,我调整了参数 shared_buffers 和 work_mem。尽管我尝试了上述参数的不同组合,但我的查询花费了相同的时间。每当更改“shared_buffer”时,我都会重新启动服务器我的环境是
Postgres 9.1 操作系统 Windows 7 内存 8GB
我尝试了 1gb、2gb 和 3gb 的 shared_buffers。但是查询执行时间变化很小(以毫秒为单位)
我正在给出查询的解释计划
GroupAggregate (cost=11100.99..12737.10 rows=50342 width=24) (actual time=181.789..268.733 rows=49829 loops=1)
-> Sort (cost=11100.99..11226.84 rows=50342 width=24) (actual time=181.761..188.323 rows=50000 loops=1)
Sort Key: (date(t_proof_of_play.play_timestamp)), (date_trunc(''hour''::text, t_proof_of_play.play_timestamp)), t_device_endpoint.venue_hierarchy_id, t_device_endpoint.device_config_id, t_proof_of_play.asset_id
Sort Method: quicksort Memory: 5443kB
-> Hash Join (cost=2629.37..7169.41 rows=50342 width=24) (actual time=15.416..112.175 rows=50000 loops=1)
Hash Cond: (t_proof_of_play.device_endpoint_id = t_device_endpoint.id)
-> Bitmap Heap Scan on t_proof_of_play (cost=2628.28..6224.41 rows=50342 width=20) (actual time=15.332..29.004 rows=50000 loops=1
Recheck Cond: ((is_processed = 0) AND (is_revenue = 1))
-> Bitmap Index Scan on process_revenue (cost=0.00..2615.69 rows=50342 width=0) (actual time=15.081..15.081 rows=50000 loops=1)
Index Cond: ((is_processed = 0) AND (is_revenue = 1))
-> Hash (cost=1.04..1.04 rows=4 width=12) (actual time=0.026..0.026 rows=4 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 1kB
-> Seq Scan on t_device_endpoint (cost=0.00..1.04 rows=4 width=12) (actual time=0.009..0.015 rows=4 loops=1)
Total runtime: 276.027 ms
欢迎提出建议。提前致谢
问候