X-Original-To: pgsql-general-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 028309FA5D8 for ; Wed, 14 Jun 2006 08:47:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 48557-02 for ; Wed, 14 Jun 2006 08:47:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from mail.gmx.net (mail.gmx.de [213.165.64.21]) by postgresql.org (Postfix) with SMTP id E60139F9CAA for ; Wed, 14 Jun 2006 08:47:19 -0300 (ADT) Received: (qmail invoked by alias); 14 Jun 2006 11:47:12 -0000 Received: from dslb-084-057-019-157.pools.arcor-ip.net (EHLO ltmku) [84.57.19.157] by mail.gmx.net (mp020) with SMTP; 14 Jun 2006 13:47:12 +0200 X-Authenticated: #23352258 From: "Milen Kulev" To: "'Jim C. Nasby'" , "'Tom Lane'" Cc: Subject: Re: Partitioning... Date: Wed, 14 Jun 2006 13:47:12 +0200 Message-ID: <010801c68fa8$46744320$0a00a8c0@trivadis.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: <20060613230917.GQ34196@pervasive.com> X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/560 X-Sequence-Number: 96932 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" 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