Re: Partitioning... - Mailing list pgsql-general

From Milen Kulev
Subject Re: Partitioning...
Date
Msg-id 010801c68fa8$46744320$0a00a8c0@trivadis.com
Whole thread Raw
In response to Re: Partitioning...  ("Jim C. Nasby" <jnasby@pervasive.com>)
Responses Re: Partitioning...
List pgsql-general
Aha !!!
Thanks Jim, the "trick" worked for me !

Regards. Milen

-----Original Message-----
From: Jim C. Nasby [mailto:jnasby@pervasive.com]
Sent: Wednesday, June 14, 2006 1:09 AM
To: Tom Lane
Cc: Milen Kulev; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Partitioning...


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


pgsql-general by date:

Previous
From: "LLC"
Date:
Subject: Compiling contrib dblink_tds and oralink
Next
From: Guido Neitzer
Date:
Subject: Copy content from dbs