Re: Auto Partitioning

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, "Markus Schiltknecht" <markus(at)bluegap(dot)ch>, "NikhilS" <nikkhils(at)gmail(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Auto Partitioning
Date: 2007-04-05 01:17:00
Message-ID: 87wt0rk4c3.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 don't have multi-table indexes how do we enforce a primary key
>> against a partitioned set? What about non primary keys that are just
>> UNIQUE? What about check constraints that aren't apart of the exclusion?
>
> I can come up with arbitrary examples that require them, but I've not
> seen one that makes sense in a real business app. Calling columns a, b
> and c disguises the validity of the example, IMHO.

Usually it comes with a situation where you want to do something like
"partition invoices by invoice_date" while simultaneously "use invoice_num" as
the primary key".

Normally the invoices numbers will be incrementing chronologically but there's
no constraint or any mechanism to enforce that or to enforce that an old
invoice number from an old partition isn't reused.

In practice I think this isn't really a serious problem though. The old
partitions are going to be read-only so you can just check that the invoice
number doesn't already exist without worrying about race conditions. And in
most cases it's being sequence-generated or something equally reliable so the
constraints are really just there as a backstop; you're not depending on them
for correctness.

At some level not having them is actually a nice thing for DBAs. It gives them
an excuse for not having the constraint that will only cause them maintenance
headaches down the road. But it's dangerous to go too far down that road.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2007-04-05 01:34:31 Re: Modifying TOAST thresholds
Previous Message Chris Browne 2007-04-05 01:11:34 Re: Modifying TOAST thresholds

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-04-05 01:47:28 Re: [HACKERS] --enable-xml instead of --with-libxml?
Previous Message ITAGAKI Takahiro 2007-04-05 00:46:40 Re: autovacuum multiworkers, patch 5