X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CA67B3ABCF7 for ; Tue, 21 Dec 2004 23:12:00 +0000 (GMT) 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 36619-03 for ; Tue, 21 Dec 2004 23:11:55 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 446693A6351 for ; Tue, 21 Dec 2004 23:11:56 +0000 (GMT) Received: by flake.decibel.org (Postfix, from userid 1001) id 085A01C8F3; Tue, 21 Dec 2004 17:11:55 -0600 (CST) Date: Tue, 21 Dec 2004 17:11:55 -0600 From: "Jim C. Nasby" To: Josh Berkus Cc: pgsql-performance@postgresql.org, Greg Stark , Stacy White Subject: Re: Partitioned table performance Message-ID: <20041221231155.GV18180@decibel.org> References: <000a01c4da74$84e072e0$0200a8c0@grownups> <200412151025.02262.josh@agliodbs.com> <87oegvqrst.fsf@stark.xeocode.com> <200412151156.40908.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200412151156.40908.josh@agliodbs.com> X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200412/268 X-Sequence-Number: 9643 On Wed, Dec 15, 2004 at 11:56:40AM -0800, Josh Berkus wrote: > Greg, > > > Well Oracle has lots of partitioning intelligence pushed up to the planner > > to avoid overhead. > > > > If you have a query with something like "WHERE date = '2004-01-01'" and > > date is your partition key (even if it's a range) then Oracle will figure > > out which partition it will need at planning time. > > Hmmm ... well, we're looking at making a spec for Postgres Table Partitioning. > Maybe you could help? This is something I've been thinking about doing for http://stats.distributed.net; is there a formal project for this somewhere? On a different note, has anyone looked at the savings you get by ommitting the partition field from the child tables? ISTM that the savings would be substantial for narrow tables. Of course that most likely means doing a union view instead of inheritence, but I'm guessing here. The table I'm thinking of partitioning is quite narrow (see below), so I suspect that dropping project_id out would result in a substantial savings (there's basically nothing that ever queries across the whole table). With the data distribution, I suspect just breaking project ID's 205, 5, and 25 into partitioned tables that didn't contain project_id would save about 450M (4bytes * 95% * 130M). (the table has ~130M rows) Table "public.email_contrib" Column | Type | Modifiers ------------+---------+----------- project_id | integer | not null id | integer | not null date | date | not null team_id | integer | work_units | bigint | not null Indexes: "email_contrib_pkey" primary key, btree (project_id, id, date) "email_contrib__pk24" btree (id, date) WHERE (project_id = 24) "email_contrib__pk25" btree (id, date) WHERE (project_id = 25) "email_contrib__pk8" btree (id, date) WHERE (project_id = 8) "email_contrib__project_date" btree (project_id, date) Foreign-key constraints: "fk_email_contrib__id" FOREIGN KEY (id) REFERENCES stats_participant(id) ON UPDATE CASCADE "fk_email_contrib__team_id" FOREIGN KEY (team_id) REFERENCES stats_team(team) ON UPDATE CASCADE stats=# select * from pg_stats where tablename='email_contrib' and attname='project_id'; schemaname | tablename | attname | null_frac | avg_width | n_distinct | most_common_vals | most_common_freqs | histogram_bounds | correlation ------------+---------------+------------+-----------+-----------+------------+-------------------+---------------------------------------------------------+------------------+------------- public | email_contrib | project_id | 0 | 4 | 6 | {205,5,25,8,24,3} | {0.461133,0.4455,0.0444333,0.0418667,0.0049,0.00216667} | | 0.703936 -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"