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

From: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
To: Omar Kilani <omar(dot)kilani(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Xia Qingran <qingran(dot)xia(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Bad performance of SELECT ... where id IN (...)
Date: 2009-10-05 12:30:28
Message-ID: 2f4958ff0910050530i7770e020m29b9535ab8107678@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Oct 5, 2009 at 1:24 PM, Omar Kilani <omar(dot)kilani(at)gmail(dot)com> wrote:

>
>
> I'm not really sure what the alternatives are -- it never really makes
> sense to get the selectivity for thousands of items in the IN clause.
> I've never seen a different plan for the same query against a DB with
> that patch vs without -- it just takes a huge amount of time longer to
> run without it. :)
>
> But yeah, definitely a hack, and should only be used if needed --
> hopefully there's some sort of official solution on the horizon. :)
>

start using temporary tables, transactions, and joins.
Depending on source of the data (if the source is another query, than just
combine it in one query with join), otherwise create temp table, fill out
with data, and run query with join.
If you do all that in transaction, it will be very fast.

--
GJ

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Adam Tauno Williams 2009-10-05 12:35:25 Re: Maybe OT, not sure Re: Best suiting OS
Previous Message Adam Tauno Williams 2009-10-05 12:28:30 Re: Best suiting OS