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 ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend