Rodrigo De León wrote:
> On 10/1/07, Abandoned <besturk@gmail.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.hertroys@magproductions.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 //