Re: Optimising "in" queries

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Stephen Davies" <scldad(at)sdc(dot)com(dot)au>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Optimising "in" queries
Date: 2007-08-22 04:20:25
Message-ID: dcc563d10708212120y3d6ee14elbd60dcf92f161730@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 8/21/07, Stephen Davies <scldad(at)sdc(dot)com(dot)au> wrote:
> I have a PostgreSQL 8.2.4 table with some seven million rows.
>
> The psql query:
>
> select count(rdate),rdate from reading where sensor_id in
> (1137,1138,1139) group by rdate order by rdate desc limit 1;
>
> takes a few seconds but:
>
> select count(rdate),rdate from reading where sensor_id in
> (1137,1138,1139,1140) group by rdate order by rdate desc limit 1;
>
> (anything with four or more values in the "in" list) takes several
> minutes.

Can we see explain analyze output? (i.e. not just plain explain)

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Steinar H. Gunderson 2007-08-22 04:24:25 Re: Poor Performance after Upgrade
Previous Message Stephen Davies 2007-08-22 02:40:36 Optimising "in" queries