Re: Bad performance of SELECT ... where id IN (...)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Xia Qingran <qingran(dot)xia(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Bad performance of SELECT ... where id IN (...)
Date: 2009-09-26 17:03:57
Message-ID: 22763.1253984637@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Xia Qingran <qingran(dot)xia(at)gmail(dot)com> writes:
> I have a big performance problem in my SQL select query:
> select * from event where user_id in
> (500,499,498, ... ,1,0);
> The above SELECT always spends 1200ms.

Your EXPLAIN ANALYZE shows that the actual runtime is only about 240ms.
So either the planning time is about 1000ms, or transmitting and
displaying the 134K rows produced by the query takes that long, or some
combination of the two. I wouldn't be too surprised if it's the data
display that's slow; but if it's the planning time that you're unhappy
about, updating to a more recent PG release might possibly help. What
version is this anyway?

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Pierre Frédéric Caillaud 2009-09-26 17:24:16 Re: PG 8.3 and large shared buffer settings
Previous Message Gerhard Wiesinger 2009-09-26 16:57:35 Re: PG 8.3 and large shared buffer settings