Skip site navigation (1) Skip section navigation (2)

Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1

From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Nikhil Sontakke" <nikhil(dot)sontakke(at)enterprisedb(dot)com>, "Emmanuel Cecchet" <manu(at)frogthinker(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1
Date: 2008-11-27 14:47:27
Message-ID: 603c8f070811270647g1f069ed5ucefbb755dac7aa58@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
>> 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

In response to

pgsql-hackers by date

Next:From: Jaime CasanovaDate: 2008-11-27 15:10:38
Subject: Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1
Previous:From: Robert HaasDate: 2008-11-27 14:41:04
Subject: Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1

pgsql-patches by date

Next:From: Jaime CasanovaDate: 2008-11-27 15:10:38
Subject: Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1
Previous:From: Robert HaasDate: 2008-11-27 14:41:04
Subject: Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group