X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 63D68D1D8BF for ; Thu, 5 Feb 2004 04:44:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 03658-03 for ; Thu, 5 Feb 2004 00:44:52 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 62F73D1D8B7 for ; Thu, 5 Feb 2004 00:44:46 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i154ip1Y075002 for ; Thu, 5 Feb 2004 04:44:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i154Kd44067994 for pgsql-admin@postgresql.org; Thu, 5 Feb 2004 04:20:39 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.admin Subject: Re: R: R: slow seqscan after vacuum analize Date: Wed, 04 Feb 2004 23:18:39 -0500 Organization: cbbrowne Computing Inc Lines: 29 Message-ID: References: <2s28b9$kqpmo@mailr-1.tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:LuEspvhf69IRbiX0q67dp+aATUc= To: pgsql-admin@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/55 X-Sequence-Number: 12229 In the last exciting episode, eddy@axa.it ("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 "~S@~S" "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,