pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Don Drake <dondrake@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Table Partitions: To Inherit Or Not To Inherit
Date: Tue, 16 Nov 2004 23:31:15 -0600
Message-ID: <6c21003b041116213166af022d@mail.gmail.com> (raw)

I've read the previous thread on the list regarding partitioning
mechanisms and I just wrote a plpgsql function to create the partition
tables (by date) as well as another function used to do the insert (it
determines which table will be inserted).

The creation of the partition tables uses the inherits clause when
creating.  It creates an exact copy of the table it's inheriting from,
and adds the indexes since inherits doesn't do that for me.

CREATE TABLE hourly_report_data_2004_11_16 () INHERITS (hourly_report_data)

When I query on the hourly_report_data, the explain plan shows it
query all the tables that inherited from it.  That's all great.

What's really the difference between this and creating separate tables
with the same column definition without the inherit, and then create a
view to "merge" them together?

Also, I've run into a snag in that I have a hourly_detail table, that
has a foreign key to the hourly_report_data.  The inherit method above
does not honor the foreign key relationship to the children table of
hourly_report_data.  I can't insert any data into the hourly_detail
table due to the constraint failing.

The hourly_detail table is relatively tiny compared to the enormous
hourly_report_data table, so if I don't have to partition that one I
would rather not.  Any suggestions on this?

Thanks.

-Don

-- 
Donald Drake
President
Drake Consulting
http://www.drakeconsult.com/
312-560-1574



view thread (2+ messages)  latest in thread

Message-ID: <6c21003b041116213166af022d@mail.gmail.com>
Permalink:  ../6c21003b041116213166af022d@mail.gmail.com/
Also on:    postgresql.org/message-id/6c21003b041116213166af022d@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dondrake@gmail.com
  Subject: Re: Table Partitions: To Inherit Or Not To Inherit
  In-Reply-To: <6c21003b041116213166af022d@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox