Re: Auto Partitioning

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Markus Schiltknecht" <markus(at)bluegap(dot)ch>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, "NikhilS" <nikkhils(at)gmail(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Auto Partitioning
Date: 2007-04-06 07:40:48
Message-ID: 87ircaj6gv.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Simon Riggs" <simon(at)2ndquadrant(dot)com> writes:

> If we partition on invoice_date only, there is an implication that
> people will search for invoices on date range only too, otherwise why
> not just partition on invoice_id. This still works with the compound key
> approach.

Well there are practical problems with partitioning on invoice_id. It's
convenient to have a predictable partition definition that can be calculated
in advance.

I suspect what people did with paper invoices is look at the last invoice for
a period and note the invoice_id down to check all future invoice_ids against.
Essentially partitioning on two separate equivalent partition keys.

We could do the same sort of thing since we're looking at constraints, there's
nothing stopping the partitions from having two separate but effectively
equivalent constraints on them. I'm not sure how to describe "partition based
on this rule for dates but note the range of invoice_ids covering a partition
and generate a constraint for that as well"

But if we could find a way to represent that it would make a lot of common use
cases much more convenient to use.

>> (But that sounds rather like pie in the sky, actually. Which other
>> databases can do that, and how do they do it?)
>
> Oracle does it, by building a big index. Few people use it.

The people that use it are the people stuck by dogmatic rules about "every
table must have a primary key" or "every logical constraint must be protected
by a database constraint". Ie, database shops run by the CYA principle.

But if a database feature is hurting you more than it's helping you then
you're not doing yourself any favours by using it. The database is a tool to
make your life easier, not something to flog yourself with to prove how good
your database design skills are.

Oracle calls these "global" indexes and imho they defeat the whole purpose
behind partitioning your data in the first place.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthew O'Connor 2007-04-06 07:53:48 Re: What X86/X64 OS's do we need coverage for?
Previous Message Mark Kirkwood 2007-04-06 07:13:34 Re: Postgres optimizer

Browse pgsql-patches by date

  From Date Subject
Next Message Takayuki Tsunakawa 2007-04-06 08:00:47 Re: Load distributed checkpoint V3
Previous Message Simon Riggs 2007-04-06 07:11:18 Re: Auto Partitioning