From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
Cc: | Rory Campbell-Lange <rory(at)campbell-lange(dot)net>, PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Update table with random values from another table |
Date: | 2009-02-12 16:13:42 |
Message-ID: | 10829.1234455222@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman(at)gmail(dot)com> writes:
> On Thu, Feb 12, 2009 at 1:10 PM, Rory Campbell-Lange
> <rory(at)campbell-lange(dot)net> wrote:
>> UPDATE
>> users
>> SET t_firstname =
>> (select firstname from testnames order by random() limit 1),
>> t_surname =
>> (select lastname from testnames order by random() limit 1)
>> WHERE
>> n_role IN (2,3);
>>
>> Doesn't return either after 60 seconds on a 8 core machine with 8GB of
>> RAM and 15K disks in R10 (no swap in use).
> That would be because, for every row in users table, postgres has to
> run two subselects, with order by random() (which in it self is quite
> expensive).
Well, no, because those subselects are independent of the parent query;
I'd expect PG to do them just once. Do they show up as "SubPlans" or
"InitPlans" in EXPLAIN?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2009-02-12 16:15:34 | Re: row constructors |
Previous Message | Kevin Kempter | 2009-02-12 15:09:38 | covering indexes? |