Re: LIMIT: does it cause the query to find all matching sets first? - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: LIMIT: does it cause the query to find all matching sets first?
Date
Msg-id 20020930151257.GA15432@wolff.to
Whole thread Raw
In response to LIMIT: does it cause the query to find all matching sets first?  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
On Mon, Sep 30, 2002 at 23:15:43 +0900,
  Jean-Christian Imbeault <jc@mega-bucks.co.jp> wrote:
> Does using LIMIT cause query execution to stop as soon as the LIMIT
> number of matches have been found, or are *all* the matching rows found
> first and then the first LIMIT number are returned?

Limit can speed things up. Even with an ordered by clause it can speed things
up (if there is an appropiate index). This can be used to quickly find
the maximum or minimum value of an indexed column.

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: current_timestamp after queries
Next
From: Tom Lane
Date:
Subject: Re: LIMIT: does it cause the query to find all matching sets first?