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

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

From: Xia Qingran <qingran(dot)xia(at)gmail(dot)com>
To: Craig James <craig_james(at)emolecules(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Bad performance of SELECT ... where id IN (...)
Date: 2009-09-27 06:13:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
On Sat, Sep 26, 2009 at 10:59 PM, Craig James
<craig_james(at)emolecules(dot)com> wrote:
> If your user_id is always in a narrow range like this, or even in any range
> that is a small fraction of the total, then add a range condition, like
> this:
> select * from event where user_id <= 500 and user_id >= 0 and user_id in
> (...)
> I did this exact same thing in my application and it worked well.
> Craig

It is a good idea. But In my application, most of the queries' user_id
are random and difficult to range.
Thanks anyway.

Xia Qingran
Sent from Beijing, 11, China
Charles de Gaulle  - "The better I get to know men, the more I find
myself loving dogs." -

In response to


pgsql-performance by date

Next:From: Gerhard WiesingerDate: 2009-09-27 07:09:26
Subject: Re: Many left outer joins with limit performance
Previous:From: Xia QingranDate: 2009-09-27 06:11:18
Subject: Re: Bad performance of SELECT ... where id IN (...)

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