我正在使用PostgreSQL 9.3有人可以帮助我,我可以做些什么来改善这一点。 db表中的最大记录数约为每日5000到7000。 PGsql DB中的shared_buffers设置为= 1GB。这里有什么不对。我的查询o / p是
EXPLAIN (BUFFERS,ANALYZE)
select sd.customer_id, ch.charge_trx_id, ch.updated_date, ch.command_tx_id, ch.mvno_id,
ch.customer_id, ch.extra_plan_id, ch.base_plan_id, ch.old_base_plan_id, ch.volume,
ch.price, ch.charge_type, ch.remarks
from charge_history ch,
subscriber_data sd
where sd.customer_id = ch.customer_id
and ch.updated_date::date = (CURRENT_DATE - integer '1')
and ch.picked_status = 'NOTPICKED';
plan:
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost=0.85..10873.44 rows=75 width=271) (actual time=0.123..51.515 rows=3982 loops=1)
Buffers: shared hit=18475 read=55682
-> Index Scan using idx_chrghist_picked_status on charge_history (cost=0.42..10239.13 rows=75 width=255) (actual time=0.092..16.022 rows=3982 loops=1)
Index Cond: (picked_status = 'NOTPICKED'::text)
Filter: ((updated_date)::date = (('now'::cstring)::date - 1))
Rows Removed by Filter: 10022
Buffers: shared hit=2547 read=55682
-> Index Scan using "CUSTOMERID" on subscriber_data (cost=0.43..8.45 rows=1 width=36) (actual time=0.008..0.008 rows=1 loops=3982)
Index Cond: ((customer_id)::text = (charge_history.customer_id)::text)
Buffers: shared hit=15928
Total runtime: 52.053 ms
(11 rows)