Re: Select too many ids..

From: Alban Hertroys <a(dot)hertroys(at)magproductions(dot)nl>
To: Rodrigo De León <rdeleonp(at)gmail(dot)com>
Cc: Abandoned <besturk(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Select too many ids..
Date: 2007-10-03 08:25:41
Message-ID: 47035205.1060808@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rodrigo De León wrote:
> On 10/1/07, Abandoned <besturk(at)gmail(dot)com> wrote:
>> Hi..
>> I have a id list and id list have 2 million dinamic elements..
>> I want to select what id have point..
>> I try:
>>
>> SELECT id, point FROM table WHERE id in (IDLIST)
>>
>> This is working but too slowly and i need to performance..
>>
>> I'm sorry my bad english.
>> King regards..
>
> DDL please...

I guess the OP's problem is with the time it takes to push a query
containing 2 million ID's through the SQL parser.

A few things that may help:

- See if you can find any uninterrupted ranges of values in your ID's
and combine them into separate where clauses (ie. where id between x and
y). This won't help you much for ranges where y = x+1, but it does help
if (for example) y = x+10...

- Try if it helps COPY-ing your ID's into a temp table and join your
table with that instead of using a huge IN list.

- If you're still using PG 7.4, try a PG 8. There have been significant
performance improvements with IN lists in queries in the 8-series.

Regards,

--
Alban Hertroys
a(dot)hertroys(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Konoplev 2007-10-03 08:44:16 Re: pg_cancel_backend() does not work with buzz queries
Previous Message Sergey Konoplev 2007-10-03 08:11:32 pg_cancel_backend() does not work with buzz queries