X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97BDAD1B345 for ; Thu, 3 Jun 2004 14:30:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28205-02 for ; Thu, 3 Jun 2004 17:30:29 +0000 (GMT) Received: from deimos.aros.net (deimos.aros.net [66.219.192.21]) by svr1.postgresql.org (Postfix) with ESMTP id B5065D1B340 for ; Thu, 3 Jun 2004 14:30:26 -0300 (ADT) Received: from [192.168.20.149] ([66.239.28.181]) (authenticated bits=0) by deimos.aros.net (8.12.9p2/8.12.9) with ESMTP id i53HUNv9034386 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 3 Jun 2004 11:30:25 -0600 (MDT) (envelope-from joseph.turner@oakleynetworks.com) From: Joseph Turner Organization: OakleyNetworks Inc To: pgsql-sql@postgresql.org Subject: Selecting "sample" data from large tables. Date: Thu, 3 Jun 2004 11:31:22 -0600 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200406031131.24535.joseph.turner@oakleynetworks.com> X-Virus-Scanned: by amavisd-new on deimos.aros.net X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200406/24 X-Sequence-Number: 17969 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have a table with a decent number of rows (let's say for example a billion rows). I am trying to construct a graph that displays the distribution of that data. However, I don't want to read in the complete data set (as reading a billion rows would take a while). Can anyone thing of a way to do this is postgresql? I've been looking online and most of the stuff I've found has been for other databases. As far as I can tell ANSI SQL doesn't provide for this scenario. I could potentially write a function to do this, however I'd prefer not to. But if that's what I'm going to be stuck doing I'd like to know earlier then later. Here's the description of the table: create table score { pageId Integer NOT NULL, ruleId, Integer NOT NULL score Double precision NULL, rowAddedDate BigInt NULL, primary key (pageId, ruleId) }; I also have an index on row added date, which is just the number of millis since the epoc (Jan 1, 1970 or so [java style timestamps]). I'd be willing to accept that the row added date values are random enough to represent random. Thanks in advance, -- Joe T. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFAv2Bqs/P36Z9SDAARAkmLAJ9dDB0sqACgFrxH8NukFUsizXz5zgCgt9IT /wh3ryz4WQzc5qQY2cAZtVE= =5dg+ -----END PGP SIGNATURE-----