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 2E35A329D3B for ; Tue, 14 Sep 2004 23:33:45 +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 63185-02 for ; Tue, 14 Sep 2004 22:33:33 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 5CA70329C6B for ; Tue, 14 Sep 2004 23:33:34 +0100 (BST) Received: by flake.decibel.org (Postfix, from userid 1001) id 4D0E11C8B7; Tue, 14 Sep 2004 17:33:33 -0500 (CDT) Date: Tue, 14 Sep 2004 17:33:33 -0500 From: "Jim C. Nasby" To: Simon Riggs Cc: pgsql-performance@postgresql.org, Mark Cotner , Christopher Browne Subject: Re: Data Warehouse Reevaluation - MySQL vs Postgres -- merge tables Message-ID: <20040914223333.GL56059@decibel.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 4.10-RELEASE-p2 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.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/128 X-Sequence-Number: 8256 On Mon, Sep 13, 2004 at 11:07:35PM +0100, Simon Riggs wrote: > PostgreSQL's functionality is in many ways similar to Oracle Partitioning. > > Loading up your data in many similar tables, then creating a view like: > > CREATE VIEW BIGTABLE (idate, col1, col2, col3...) AS > SELECT 200409130800, col1, col2, col3... FROM table200409130800 > UNION ALL > SELECT 200409131000, col1, col2, col3... FROM table200409131000 > UNION ALL > SELECT 200409131200, col1, col2, col3... FROM table200409131200 > ...etc... > > will allow the PostgreSQL optimizer to eliminate partitions from the query > when you run queries which include a predicate on the partitioning_col, e.g. > > select count(*) from bigtable where idate >= 200409131000 > > will scan the last two partitions only... > > There are a few other ways of creating the view that return the same answer, > but only using constants in that way will allow the partitions to be > eliminated from the query, and so run for much longer. Is there by any chance a set of functions to manage adding and removing partitions? Certainly this can be done by hand, but having a set of tools would make life much easier. I just looked but didn't see anything on GBorg. -- 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?"