Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 88A919FBF36 for ; Tue, 23 Oct 2007 10:36:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 33637-08 for ; Tue, 23 Oct 2007 10:36:50 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 34E6C9FBF32 for ; Tue, 23 Oct 2007 10:36:50 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IkJw0-0005UN-8G for pgsql-performance@postgresql.org; Tue, 23 Oct 2007 13:36:41 +0000 Received: from cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk ([80.63.167.178]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Oct 2007 13:36:40 +0000 Received: from nis by cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Oct 2007 13:36:40 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: =?ISO-8859-1?Q?Nis_J=F8rgensen?= Subject: Re: Seqscan Date: Tue, 23 Oct 2007 15:36:21 +0200 Lines: 38 Message-ID: References: <1193107511.26301.59.camel@jdavis> <766975.88585.qm@web50908.mail.re2.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) In-Reply-To: <766975.88585.qm@web50908.mail.re2.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/250 X-Sequence-Number: 27272 (Please don't top-post. ) Adrian Demaestri skrev: > */Jeff Davis /* escribió: > > On Mon, 2007-10-22 at 19:24 -0700, Adrian Demaestri wrote: > > Hi, > > I think planner should use other plans than seqscan to solve querys > > like select * from hugetable limit 1, especially when the talbe is > > very large. Is it solved in newer versions or is there some open > > issues about it?. > > thanks > > I'm working with postgres 8.0.1, > > For the query in question, what would be faster than a seqscan? It > doesn't read the whole table, it only reads until it satisfies the limit > clause. > It is not actualy a table, sorry, it is a quite complex view that > involve three large tables. If hugetable isn't a table, you chose a really bad name for it. What you have here is a specific query performing badly, not a generic issue with all queries containing "LIMIT X". You might of course have found a construct which the planner has problems with - but the first step is to let us see the result of EXPLAIN ANALYZE. Anyway, I think you might be hitting this issue: "Fix mis-planning of queries with small LIMIT values due to poorly thought out "fuzzy" cost comparison" (http://www.postgresql.org/docs/8.0/static/release-8-0-4.html) which was fixed in 8.0.4 . You should upgrade. Nis