Re: LIMIT clause optimization

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Felipe Schnack <felipes(at)ritterdosreis(dot)br>
Cc: Holger Klawitter <lists(at)klawitter(dot)de>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: LIMIT clause optimization
Date: 2003-01-07 13:16:58
Message-ID: 20030107131658.GA6839@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 07, 2003 at 10:44:15 -0200,
Felipe Schnack <felipes(at)ritterdosreis(dot)br> wrote:
> Why? I don't understand. If I create a query and want just the first
> row from it, wouldn't speed up things a lot just adding "LIMIT 1" in the
> end of the query?

That depends on the query. For some queries you will only see a small
speed up. It is also possible for limit to effect the optimization results
in a way that ends up slowing things down (though that should be rare)
because an inferior plan ends up being chosen.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2003-01-07 13:22:47 Re: LIMIT clause optimization
Previous Message Felipe Schnack 2003-01-07 13:14:46 Re: LIMIT clause optimization