Re: Performance Concern - Mailing list pgsql-performance

From Hannu Krosing
Subject Re: Performance Concern
Date
Msg-id 1067116415.3991.4.camel@fuji.krosing.net
Whole thread Raw
In response to Re: Performance Concern  ("John Pagakis" <thebfh@toolsmythe.com>)
Responses Re: Performance Concern
List pgsql-performance
John Pagakis kirjutas L, 25.10.2003 kell 12:56:

> I wrote a JAVA simulation of the above that did 1000 updates in 37 seconds.
> That left me scratching my head because in psql when I did the
> semi-equivalent:
>
> UPDATE baz SET customer_id = '1234' WHERE baz_key IN( SELECT baz_key FROM
> baz WHERE customer_id IS NULL LIMIT 1000 );

try it this way, maybe it will start using an index :

UPDATE baz
   SET customer_id = '1234'
 WHERE baz_key IN (
    SELECT baz_key
      FROM baz innerbaz
     WHERE customer_id IS NULL
       and innerbaz.baz_key = baz.baz_key
     LIMIT 1000 );

you may also try to add a conditional index to baz:

CREATE INDEX baz_key_with_null_custid_nxd
    ON  baz
 WHERE customer_id IS NULL;

to make the index access more efficient.

----------------
Hannu


pgsql-performance by date:

Previous
From: "John Pagakis"
Date:
Subject: Re: Performance Concern
Next
From: Bruce Momjian
Date:
Subject: Re: analyzing postgresql performance for dbt-2