Performance Killer 'IN' ? - Mailing list pgsql-general

From Kai Hessing
Subject Performance Killer 'IN' ?
Date
Msg-id 492752FmfdpeU1@individual.net
Whole thread Raw
Responses Re: Performance Killer 'IN' ?  (Kai Hessing <kai.hessing@hobsons.de>)
List pgsql-general
Hossa,

I just made a little test on our test-database. I have an excel sheet
with about 2000 entries that should be updated with the same value. In a
first try I generated an SQL-Syntax for every entry like:

UPDATE xyz SET status=-6 WHERE id=xyz1 AND status>-1;
UPDATE xyz SET status=-6 WHERE id=xyz2 AND status>-1;
UPDATE xyz SET status=-6 WHERE id=... AND status>-1;

The execution of the ~2000 SQL-commands took about 5-10 seconds.

Then I tried the same with generating only one request using IN with the
twothousand entries like:

UPDATE xyz WHERE id IN (xyz1, xyz2, ....) AND status>-1;

and it took about 10 Minutes to execute. So it is nearly a hundred times
slower. Can this be verified? Is there anything that can be done about
that? Else I would need to have a few words with our programmers...

By the way the testsystem is a basic Suse 9.3 with a default postgres
installation 8.0.x

Thanks and
*greets*
Kai

pgsql-general by date:

Previous
From: "Bozhidar Mihaylov"
Date:
Subject: Slony-I for circular replication
Next
From: Kai Hessing
Date:
Subject: Re: Performance Killer 'IN' ?