X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 08A72D1B8A7 for ; Sat, 30 Aug 2003 16:19:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 44997-06 for ; Sat, 30 Aug 2003 13:18:29 -0300 (ADT) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by svr1.postgresql.org (Postfix) with ESMTP id CCCB5D1B8B2 for ; Sat, 30 Aug 2003 13:18:28 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.06.04 201-253-122-130-104-20030726) with ESMTP id <20030830161828.GMMG11854.lakemtao02.cox.net@lhosts> for ; Sat, 30 Aug 2003 12:18:28 -0400 Subject: Re: Selecting random rows efficiently From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <1062252117.83670.29.camel@jester> References: <200308301425.51127.rj@last.fm> <1062252117.83670.29.camel@jester> Content-Type: text/plain Message-Id: <1062260304.669.566.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Sat, 30 Aug 2003 11:18:25 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/538 X-Sequence-Number: 3354 On Sat, 2003-08-30 at 09:01, Rod Taylor wrote: > > i was hoping there was some trickery with sequences that would allow me to > > easily pick a random valid sequence number..? > > I would suggest renumbering the data. > > ALTER SEQUENCE ... RESTART WITH 1; > UPDATE table SET pkey = DEFAULT; > > Of course, PostgreSQL may have trouble with that update due to > evaluation of the unique constraint immediately -- so drop the primary > key first, and add it back after. And if there are child tables, they'd all have to be updated, too. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "Whatever may be the moral ambiguities of the so-called demoratic nations and however serious may be their failure to conform perfectly to their democratic ideals, it is sheer moral perversity to equate the inconsistencies of a democratic civilization with the brutalities which modern tyrannical states practice." Reinhold Nieburhr, ca. 1940