Re: LIMIT Question

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Terry Lee Tucker" <terry(at)chosen-ones(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: LIMIT Question
Date: 2008-02-28 23:32:52
Message-ID: dcc563d10802281532n3da2ee0dlc2114f23af8136b8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 28, 2008 at 3:20 PM, Terry Lee Tucker <terry(at)chosen-ones(dot)org> wrote:
> When one uses LIMIT, as in LIMIT 1, is the entire query executed on the server
> side, but only one record returned?
>
> --------------------------------------------------------------------------------------------------------
> PostgreSQL 7.4.19 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.4.6
> 20060404 (Red Hat 3.4.6-9)

Sometimes yes, sometimes no. Depends on how complex the query is and
whether or not pgsql's query planner can see a shortcut or not. It's
more likely that a later version will have the optimizations needed to
do that than an older version like 7.4 I'd think. But I'd ask someone
more expert on the planner like Tom to be sure.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2008-02-28 23:34:40 Re: "Consider compacting this relation..." ???
Previous Message John Evans 2008-02-28 23:24:42 Re: WAL Log Size