| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | "Robert Wille" <robertw(at)willeweb(dot)com> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Why are queries with subselects so slow? | 
| Date: | 2003-03-07 14:54:57 | 
| Message-ID: | 195.1047048897@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
"Robert Wille" <robertw(at)willeweb(dot)com> writes:
> [ this is awfully slow: ]
> update image set state =3D ((state & -35184340369664::int8) | 0::int8) wher=
> e containerid in (select containerid from ancestry where ancestorid =3D 122=
> 8067)
IN is notoriously slow.  It'll be better in 7.4, but in the meantime
it's best avoided.  It appears from your schema that the subselect
cannot generate duplicate containerids, so you should be able to do
it like this:
update image set state = ((state & -35184340369664::int8) | 0::int8)
from ancestry
where image.containerid = ancestry.containerid
      and ancestry.ancestorid = 1228067;
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | valerian | 2003-03-07 16:04:23 | Re: index on lower(column) is very slow | 
| Previous Message | Tom Lane | 2003-03-07 14:38:39 | Re: password method in pg_hba.conf fails |