Re: From Simple to Complex

From: Alessandro Gagliardi <alessandro(at)path(dot)com>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: From Simple to Complex
Date: 2012-02-01 18:48:33
Message-ID: CAAB3BB+8-7CQi+CmbFBsUZ1RRkKPvCnr4aPW6s48i1fC-ZKb6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

LIMIT 65536; Total query runtime: 14846 ms. -
http://explain.depesz.com/s/I3E
LIMIT 69632: Total query runtime: 80141 ms. -
http://explain.depesz.com/s/9hp

So it looks like when the limit crosses a certain threshold (somewhere
north of 2^16), Postgres decides to do a Seq Scan instead of an Index Scan.
I've already lowered random_page_cost to 2. Maybe I should lower it to 1.5?
Actually 60K should be plenty for my purposes anyway.

On Wed, Feb 1, 2012 at 10:35 AM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>wrote:

> On Wed, Feb 1, 2012 at 11:19 AM, Alessandro Gagliardi
> <alessandro(at)path(dot)com> wrote:
> > Interestingly, increasing the limit does not seem to increase the
> runtime in
> > a linear fashion. When I run it with a limit of 60000 I get a runtime
> > of 14991 ms. But if I run it with a limit of 70000 I get a runtime
> of 77744
> > ms. I assume that that's because I'm hitting a memory limit and paging
> out.
> > Is that right?
>
> Hard to say. more likely your query plan changes at that point. Run
> the queries with "explain analyze" in front of them to find out.
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Gudmundur Johannesson 2012-02-01 18:50:09 Re: Index with all necessary columns - Postgres vs MSSQL
Previous Message Scott Marlowe 2012-02-01 18:35:31 Re: From Simple to Complex