Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-performance by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group