Performance Killer 'IN' ?

From: Kai Hessing <kai(dot)hessing(at)hobsons(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Performance Killer 'IN' ?
Date: 2006-03-30 14:09:38
Message-ID: 492752FmfdpeU1@individual.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2006-03-30 14:15:40 Re: Slony-I for circular replication
Previous Message Mark Aufflick 2006-03-30 13:48:10 Re: PostgreSQL x Sybase