In the last exciting episode, [EMAIL PROTECTED] ("Edoardo Ceccarelli") wrote: > Yes, you are right but it wasn't the case this time, I have run the > explain plenty of times with same results. I think that the reason > was that I made a simple VACUUM, after a VACUUM FULL ANALYZE (1h!!) > things are ok
It sounds as though you weren't vacuuming ("just plain vacuum") often enough. What tends to go wrong is when the table winds up with a LOT of empty space due to there being a lot of updates to the table without dead tuples being cleaned out. The table winds up big, with no way to shrink it without the cost of a VACUUM FULL. If you vacuumed more often, the size of the table would likely stay smaller which is sure to be helpful. Another factor worth considering: If a few values are very common in the field you are selecting on, then the query optimizer can get convinced (wrongly) that a Seq Scan is the best choice. Using ALTER TABLE T ALTER COLUMN C SET STATISTICS [some value] to increase the number of "bins" can be helpful in such cases. (My pet theory is that the present default value of 10 is a little low, and that a lot of optimizer errors might be resolved by bumping it up a bit...) -- (format nil "[EMAIL PROTECTED]" "cbbrowne" "ntlug.org") http://www.ntlug.org/~cbbrowne/sgml.html But what can you do with it? -- ubiquitous cry from Linux-user partner. -- Andy Pearce, <[EMAIL PROTECTED]> ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend