Re: Partitioning...

From: "Milen Kulev" <makulev(at)gmx(dot)net>
To: "'Jim C(dot) Nasby'" <jnasby(at)pervasive(dot)com>, "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Partitioning...
Date: 2006-06-14 11:47:12
Message-ID: 010801c68fa8$46744320$0a00a8c0@trivadis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Aha !!!
Thanks Jim, the "trick" worked for me !

Regards. Milen

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

On Mon, Jun 12, 2006 at 06:58:06PM -0400, Tom Lane wrote:
> "Milen Kulev" <makulev(at)gmx(dot)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(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guido Neitzer 2006-06-14 11:56:06 Copy content from dbs
Previous Message Martijn van Oosterhout 2006-06-14 10:39:21 Re: Me And My Database