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 ECF14329E32 for ; Thu, 16 Sep 2004 22:59:25 +0100 (BST) 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 09486-01 for ; Thu, 16 Sep 2004 21:59:14 +0000 (GMT) Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) by svr1.postgresql.org (Postfix) with ESMTP id 245A5329D41 for ; Thu, 16 Sep 2004 22:59:12 +0100 (BST) Received: from [65.87.16.98] (HELO vulture.corp.neopolitan.com) by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 5881885; Thu, 16 Sep 2004 14:59:12 -0700 Subject: Re: Partitioning From: "J. Andrew Rogers" To: "Jim C. Nasby" Cc: pgsql-performance@postgresql.org In-Reply-To: <20040916203951.GE56059@decibel.org> References: <20040914223333.GL56059@decibel.org> <60k6uw1cqa.fsf@dev6.int.libertyrms.info> <4147C560.9060702@joeconway.com> <1095282571.25123.181.camel@vulture.corp.neopolitan.com> <20040916203951.GE56059@decibel.org> Content-Type: text/plain Organization: Message-Id: <1095371952.28387.73.camel@vulture.corp.neopolitan.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 16 Sep 2004 14:59:12 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/181 X-Sequence-Number: 8309 On Thu, 2004-09-16 at 13:39, Jim C. Nasby wrote: > Forgive my ignorance, but I didn't think you could have a table that > inherits from a parent not have all the columns. Or is that not what you > mean by 'you can drop columns from the table...'? > > This is one advantage I see to a big UNION ALL view; if you're doing > partitioning based on unique values, you don't actually have to store > that value in the partition tables. For example, > http://stats.distributed.net has a table that details how much work each > participant did each day for each project. Storing project_id in that > table is an extra 4 bytes... doesn't sound like much until you consider > that the table has over 130M rows right now. So it would be nice to have > an easy way to partition the table based on unique project_id's and not > waste space in the partition tables on a field that will be the same for > every row (in each partition). Yeah, it is harder to do this automagically, though in theory it should be possible. Since we have to roll our own partitioning anyway, we've broken up composite primary keys so that one of the key columns hashes to a partition, using the key itself in the partition table name rather than replicating that value several million times. Ugly as sin, but you can make it work in some cases. I do just enough work for our queries to behave correctly, and a lot of times I actually hide the base table and its descendents underneath a sort of metadata table that is grafted to the base tables by a lot of rules/triggers/functions/etc, and then do queries against that or a view of that. As I said, ugly as sin and probably not universal, but you need a lot of abstraction to make it look halfway normal. I'm going to think about this some more and see if I can't construct a generic solution. cheers, j. andrew rogers