我正在研究一個帶有aprox表的系統。 1300萬條記錄。 這對於postgres來說似乎沒什麼大不了的,但是當遇到這個特定的表時,我遇到了嚴重的性能問題。Postgres在過濾器或集合上的AWS性能問題
該表有aprox。 60列(我知道它太多了,但我無法改變它,因爲超出我的意願的原因)。
硬件沒問題。它在AWS上運行。我測試了幾種配置,甚至是新的RDS for postgres:
vCPU ECU mem(gb)
m1.xlarge 64 bits 4 8 15
m2.xlarge 64 bits 2 6,5 17
hs1.8xlarge 64 bits 16 35 117 SSD
我用pgtune調整了pg設置。並且設置ubuntu的內核sshmall和shmmax。
一些 「解釋分析」 查詢:
從SELECT COUNT(*):
$Aggregate (cost=350390.93..350390.94 rows=1 width=0) (actual time=24864.287..24864.288 rows=1 loops=1)
-> Index Only Scan using core_eleitor_sexo on core_eleitor (cost=0.00..319722.17 rows=12267505 width=0) (actual time=0.019..12805.292 rows=12267505 loops=1)
Heap Fetches: 9676
Total runtime: 24864.325 ms
選擇不同core_eleitor_city來自:
HashAggregate (cost=159341.37..159341.39 rows=2 width=516) (actual time=15965.740..15966.090 rows=329 loops=1)
-> Bitmap Heap Scan on core_eleitor (cost=1433.53..159188.03 rows=61338 width=516) (actual time=956.590..9021.457 rows=5886110 loops=1)
Recheck Cond: ((core_eleitor_city)::text = 'RIO DE JANEIRO'::text)
-> Bitmap Index Scan on core_eleitor_city (cost=0.00..1418.19 rows=61338 width=0) (actual time=827.473..827.473 rows=5886110 loops=1)
Index Cond: ((core_eleitor_city)::text = 'RIO DE JANEIRO'::text)
Total runtime: 15977.460 ms
我對經常用於列B樹索引過濾器或聚合。
因此,鑑於我無法改變我的餐桌設計。有什麼我可以做的改善表現?
任何幫助都會很棒。
感謝
注意:OP指的是Postgres,它在RDS上沒有隻讀副本功能。 –
@MalCurtis謝謝.. !!! –