Hi,
I have a history house keeping problem on Zabbix 1.6.5 with postgresql 8.3.7.
After I detete items, the posgresql becomes so slow bacause it delete rows from history.
I found slow query in the housekeeping process. The query is like this.
'delete from history where oid in (select oid from history where itemid=59692 limit 500)'.
Explain result shows oid column does not have index, so that query is so slow.
1. Do I miss any configuration on postgres.conf?
2. Do I need to create index on history.oid?
Thanks.
Following are the explain result.
Just delete all items is much faster.
I have a history house keeping problem on Zabbix 1.6.5 with postgresql 8.3.7.
After I detete items, the posgresql becomes so slow bacause it delete rows from history.
I found slow query in the housekeeping process. The query is like this.
'delete from history where oid in (select oid from history where itemid=59692 limit 500)'.
Explain result shows oid column does not have index, so that query is so slow.
1. Do I miss any configuration on postgres.conf?
2. Do I need to create index on history.oid?
Thanks.
Following are the explain result.
Code:
zabbix=> explain analyze delete from history where oid in (select oid from history where itemid=59692 limit 500);
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=1845.48..3889990.24 rows=200 width=6) (actual time=3267.019..1967420.522 rows=500 loops=1)
Hash Cond: (public.history.oid = public.history.oid)
-> Seq Scan on history (cost=0.00..3169308.46 rows=191689146 width=10) (actual time=2.619..1017835.038 rows=191638412 loops=1)
-> Hash (cost=1842.98..1842.98 rows=200 width=4) (actual time=1761.001..1761.001 rows=500 loops=1)
-> HashAggregate (cost=1840.98..1842.98 rows=200 width=4) (actual time=1755.972..1758.406 rows=500 loops=1)
-> Limit (cost=0.00..1834.73 rows=500 width=4) (actual time=52.219..1752.270 rows=500 loops=1)
-> Index Scan using history_1 on history (cost=0.00..190478.40 rows=51909 width=4) (actual time=52.210..1747.080 rows=500 loops=1)
Index Cond: (itemid = 59692)
Total runtime: 1967463.630 ms
(9 rows)
zabbix=>
Code:
zabbix=> explain analyze delete from history where itemid=59692;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
Bitmap Heap Scan on history (cost=1750.53..175079.41 rows=51909 width=6) (actual time=895.067..5271.856 rows=5106 loops=1)
Recheck Cond: (itemid = 59692)
-> Bitmap Index Scan on history_1 (cost=0.00..1737.55 rows=51909 width=0) (actual time=887.039..887.039 rows=5606 loops=1)
Index Cond: (itemid = 59692)
Total runtime: 5838.779 ms
(5 rows)



Comment