Re: Limit & offset effect on query plans

From: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
To: Amitabh Kant <amitabhkant(at)gmail(dot)com>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Limit & offset effect on query plans
Date: 2012-12-13 04:43:26
Message-ID: CABOikdMW8xO4NpigJz+9ruFjMhNp=c=6fU5ms6LGMdGmzDqbjQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Dec 13, 2012 at 9:38 AM, Amitabh Kant <amitabhkant(at)gmail(dot)com> wrote:
> Hi
>
> Our scripts automatically add "LIMIT ALL" & "OFFSET 0" to every select query
> if no values are passed on for these parameters. I remember reading through
> the mailing list that it's better not to pass them if they are not needed as
> they add a cost to the query plan. Is this the case, or am i looking at a
> very minor optimization.
>

I would tend to think that is the latter. While undoubtedly
limit/offset clause will add another node during query planning and
execution, AFAICS the OFFSET 0 and LIMIT ALL cases are optimized to a
good extent. So the overhead of having them will not be significant.

Thanks,
Pavan

--
Pavan Deolasee
http://www.linkedin.com/in/pavandeolasee

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Pavan Deolasee 2012-12-13 04:48:48 Re: [PERFORM] encouraging index-only scans
Previous Message Amitabh Kant 2012-12-13 04:08:09 Limit & offset effect on query plans