I am using postgres version-- PostgreSQL 7.2.3 on i686-pc-linux-gnu. My db query was going slow. I came to know that using vacuum u can clear some space captured by unneccesory data. ( left by delete query etc..). and also it improves performance by modifying statastics..So I did vacuum and before vacuum I noted cost and it was
(cost=1745428.46..1745428.46 rows=4 width=604)
-> Sort (cost=1745428.46..1745428.46 rows=4 width=604)
-> Hash Join (cost=1845.38..1745428.41 rows=4 width=604)
-> Seq Scan on correspondence c (cost=0.00..1743574.23 rows=1749 width=12)
SubPlan
-> Materialize (cost=498.37..498.37 rows=350 width=8)
-> Aggregate (cost=480.88..498.37 rows=350 width=8)
-> Group (cost=480.88..489.62 rows=3498 width=8)
-> Sort (cost=480.88..480.88 rows=3498 width=8)
-> Seq Scan on correspondence (cost=0.00..274.98 rows=3498 width=8)
-> Hash (cost=1845.38..1845.38 rows=3 width=592)
-> Seq Scan on ticket t (cost=0.00..1845.38 rows=3 width=592)
SubPlan
-> Materialize (cost=1.69..1.69 rows=1 width=4)
-> Seq Scan on group_user (cost=0.00..1.69 rows=1 width=4)
now after vacuum I am getting this result for the same query...
(cost=5439902.60..5439902.60 rows=30 width=973)
-> Sort (cost=5439902.60..5439902.60 rows=127 width=973)
-> Hash Join (cost=4720.89..5439898.18 rows=127 width=973)
-> Seq Scan on correspondence c (cost=0.00..5435158.18 rows=2338 width=480)
SubPlan
-> Materialize (cost=1162.17..1162.17 rows=468 width=8)
-> Aggregate (cost=1138.79..1162.17 rows=468 width=8)
-> Group (cost=1138.79..1150.48 rows=4676 width=8)
-> Sort (cost=1138.79..1138.79 rows=4676 width=8)
-> Seq Scan on correspondence (cost=0.00..853.76 rows=4676 width=8)
-> Hash (cost=4720.65..4720.65 rows=93 width=493)
-> Seq Scan on ticket t (cost=0.00..4720.65 rows=93 width=493)
SubPlan
-> Materialize (cost=1.74..1.74 rows=1 width=4)
-> Seq Scan on group_user (cost=0.00..1.74 rows=1 width=4)
and now for each vacuum cost is increasing...I thought there must be some problem while vacuuming so i did another vacuum and my next vacuum gave me below cost..
(cost=5674096.27..5674096.27 rows=30 width=981).....
I used query VACUUM VERBOSE ANALYZE for vacuuming...
I can't understand what is happening...
Can anybody help me..!!!!!!
thanks in advance..