pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hannu Krosing <hannu@tm.ee>
To: thebfh@toolsmythe.com
Cc: john@pagakis.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance Concern
Date: Sun, 26 Oct 2003 00:13:36 +0300
Message-ID: <1067116415.3991.4.camel@fuji.krosing.net> (raw)
In-Reply-To: <KKEBKDPPLALEFHBEAOCCIEDFDEAA.thebfh@toolsmythe.com>
References: <KKEBKDPPLALEFHBEAOCCIEDFDEAA.thebfh@toolsmythe.com>

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




view thread (16+ messages)  latest in thread

Message-ID: <1067116415.3991.4.camel@fuji.krosing.net>
Permalink:  ../1067116415.3991.4.camel@fuji.krosing.net/
Also on:    postgresql.org/message-id/1067116415.3991.4.camel@fuji.krosing.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: hannu@tm.ee, thebfh@toolsmythe.com, john@pagakis.com
  Subject: Re: Performance Concern
  In-Reply-To: <1067116415.3991.4.camel@fuji.krosing.net>
  References: <KKEBKDPPLALEFHBEAOCCIEDFDEAA.thebfh@toolsmythe.com> <1067116415.3991.4.camel@fuji.krosing.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox