X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 970F73A46DF for ; Thu, 11 Nov 2004 17:06:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35967-09 for ; Thu, 11 Nov 2004 17:06:24 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2A6013A4A47 for ; Thu, 11 Nov 2004 15:24:05 +0000 (GMT) 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 iABFO4g7001466 for ; Thu, 11 Nov 2004 15:24:05 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAB83YAS090135 for pgsql-performance@postgresql.org; Thu, 11 Nov 2004 08:03:34 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: vacuum analyze slows sql query Date: Thu, 11 Nov 2004 09:03:24 +0100 Organization: PYRENET Midi-pyrenees Provider Lines: 31 Message-ID: <41931CCC.6070803@bigfoot.com> References: <419008DA.3000007@johnmeinel.com> <20041109192644.6423.qmail@web52104.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: patrick ~ User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en In-Reply-To: <20041109192644.6423.qmail@web52104.mail.yahoo.com> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/182 X-Sequence-Number: 9136 patrick ~ wrote: > --- John Meinel wrote: > > >>If you are trying to establish existence, we also had a whole thread on >>this. Basically what we found was that adding an ORDER BY clause, helped >>tremendously in getting the planner to switch to an Index scan. You >>might try something like: >> >>SELECT column FROM mytable WHERE column='myval' ORDER BY column LIMIT 1; >> >>There seems to be a big difference between the above statement and: >> >>SELECT column FROM mytable WHERE column='myval' LIMIT 1; > > > > The ORDER BY "trick" worked beautifully! I just hope it'll > continue to work consistently in production code. For sure it will not break the goal: "check the existence". Regards Gaetano Mendola