From: Jim C. Nasby <jnasby@pervasive.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Milen Kulev <makulev@gmx.net>
Cc: pgsql-general@postgresql.org
Subject: Re: Partitioning...
Date: Tue, 13 Jun 2006 18:09:17 -0500
Message-ID: <20060613230917.GQ34196@pervasive.com> (raw)
In-Reply-To: <13439.1150153086@sss.pgh.pa.us>
References: <007701c68e6f$0e992770$0a00a8c0@trivadis.com>
<13439.1150153086@sss.pgh.pa.us>
On Mon, Jun 12, 2006 at 06:58:06PM -0400, Tom Lane wrote:
> "Milen Kulev" <makulev@gmx.net> writes:
> > What is wrong with random() ?
>
> Not guaranteed to be stable across the multiple evaluations that the
> rule will perform ... remember a rule is a macro and has the usual
> multiple-evaluation gotchas in the face of volatile arguments.
I believe a safe alternative would be...
INSERT INTO ... SELECT * FROM
(SELECT random()*20 FROM ...)
;
You might need to add an ORDER BY to the subquery to ensure PostgreSQL
doesn't pull it into the main query.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
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-general@postgresql.org
Cc: jnasby@pervasive.com, tgl@sss.pgh.pa.us, makulev@gmx.net
Subject: Re: Partitioning...
In-Reply-To: <20060613230917.GQ34196@pervasive.com>
References: <007701c68e6f$0e992770$0a00a8c0@trivadis.com> <13439.1150153086@sss.pgh.pa.us> <20060613230917.GQ34196@pervasive.com>
* 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