Skip site navigation (1) Skip section navigation (2)

Re: LIMIT Question

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>, "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, "Terry Lee Tucker" <terry(at)chosen-ones(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: LIMIT Question
Date: 2008-02-29 11:58:29
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Fri, Feb 29, 2008 at 3:55 PM, Martijn van Oosterhout <kleptog(at)svana(dot)org>

> On Fri, Feb 29, 2008 at 02:53:05PM +0530, Gurjeet Singh wrote:
> > In my opinion (without looking at the code), if you have a
> grouping-function
> > or ORDER BY or GROUP BY clause, then yes, the whole query has to be
> executed
> > to show the first row of the result-set. But if the query doesn't have
> any
> > of these clauses, then the DB has the ability to send back the first row
> > from the result as soon as it processes it (i.e after WHERE clause
> > processing), and stop the query execution there.
> Except if you have an index on the column you're ordering by. Then the
> server can really return the first row quickly.

Quickly for sure... but I don't think 'without processing all the rows that
qualify'. I think it will still process all the rows and return just one.

Best regards,
singh(dot)gurjeet(at){ gmail | hotmail | indiatimes | yahoo }.com


17° 29' 34.37"N,  78° 30' 59.76"E - Hyderabad
18° 32' 57.25"N,  73° 56' 25.42"E - Pune *
37° 47' 19.72"N, 122° 24' 1.69" W - San Francisco

Mail sent from my BlackLaptop device

In response to


pgsql-general by date

Next:From: Sam MasonDate: 2008-02-29 13:50:28
Subject: Re: LIMIT Question
Previous:From: Martijn van OosterhoutDate: 2008-02-29 10:25:41
Subject: Re: LIMIT Question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group