Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id F076164FDD1 for ; Thu, 27 Nov 2008 10:47:31 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 82945-08 for ; Thu, 27 Nov 2008 10:47:29 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by mail.postgresql.org (Postfix) with ESMTP id 00D6D64FD6F for ; Thu, 27 Nov 2008 10:47:28 -0400 (AST) Received: by fg-out-1718.google.com with SMTP id 16so672324fgg.23 for ; Thu, 27 Nov 2008 06:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=G2GC+FzRvS8QHcPXfzC6Mew3t9EU8OnTLXcX8mKKI9Y=; b=gN/zc0Hb5PznsH2JdafQ8FNpvU98Ipw3DcJdaQmR4EqT+setgsmpi/99sHRbcnS8FJ iVj1CVuMtiMkaaunrcvyU5NRQ50sLLZIED3K1lmiq+Bx4+wz0Db+H19OParvCB3ew+ky kHMjJ15s88FrcI0qeDr2DLq0G6h6W830jTgDA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=MGsKD94Y5/3jqXxkJJmyAgCPK1e7clxfZ+EuMW0zETfAK3grbg1uIbj2pTGQoe744T fn1D7kT4zriaYU5InV13o0rvAv/GctHj2T7VEIVCPTqwhIF//qjFgCY1qOnG5/Rsqfvg B0qQMNSUNUh4wk6J6upqVEFLdgB2TCYCDbLjo= Received: by 10.187.248.10 with SMTP id a10mr1597296fas.91.1227797247157; Thu, 27 Nov 2008 06:47:27 -0800 (PST) Received: by 10.187.221.3 with HTTP; Thu, 27 Nov 2008 06:47:27 -0800 (PST) Message-ID: <603c8f070811270647g1f069ed5ucefbb755dac7aa58@mail.gmail.com> Date: Thu, 27 Nov 2008 09:47:27 -0500 From: "Robert Haas" To: "Jaime Casanova" Subject: Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1 Cc: "Alvaro Herrera" , "Nikhil Sontakke" , "Emmanuel Cecchet" , PostgreSQL-development In-Reply-To: <3073cc9b0811270601m6a7691dcg5f2ea6d4172b0d38@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <3073cc9b0810220744y987173avd560a33fcb58ede5@mail.gmail.com> <3073cc9b0811052047o4ebe24b4vd0ab24fd3095d342@mail.gmail.com> <3073cc9b0811261335q5e35d336i33faa17eede7d417@mail.gmail.com> <603c8f070811261352ta6da0b8xcbb8aaf87f050e6e@mail.gmail.com> <3073cc9b0811261613l18e5283ft448ea74fed414dd@mail.gmail.com> <603c8f070811262009v459d0701w151c16533d4ab947@mail.gmail.com> <20081127120402.GC4586@alvh.no-ip.org> <603c8f070811270507i36e18e0bu5d461a4f957e24d3@mail.gmail.com> <3073cc9b0811270601m6a7691dcg5f2ea6d4172b0d38@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.41 tagged_above=0 required=5 tests=SUBJECT_FUZZY_TION=0.41 X-Spam-Level: X-Archive-Number: 200811/1821 X-Sequence-Number: 128533 >> I like the idea of using table inheritance as a foundation for this >> feature, but I think it's not going to be very useful for real-world >> applications without cross-table indexes. Suppose for example that I >> have five years worth of data (thus, 60 partitions) and each >> transaction has a unique identifier of some sort that is unrelated to >> the date. It's bad enough that a query like this has to check every >> partition: > you haven't. the WHERE clause in your hipotetical CREATE PARTITION > should create a check constraint on the child (inherited) table and if > you have constraint_exclusion to on you will check just the > partition(s) that match with the check constraint. The problem is that constraint exclusion will not be able to exclude anything for queries unrelated to the partition key. If my transactions are identified by UUIDs or similar, there's no way to predict which table will contain any particular value. You end up having to scan them all, and even if they all have individual indices on the column in question, that's still 60 index scans instead of 1. >> What's even worse (at least IMHO) is that there's no way to use >> transaction (uuid) as a reference for a foreign key. > not directly, but you always can create a trigger instead of the > foreign key constraint... > mmm...the docs says that there is no good workaround, what about > mention a trigger? I think it's pretty hard to make this bulletproof. I think the triggers that enforce ordinary foreign key constraints contain some magical cross-checks on transaction commit that can't easily be emulated by user-written triggers. In any case, it's a long way from "Oh, yeah, that just works." ...Robert