Thread: smart or dumb partition?

smart or dumb partition?

From
Bob Gobeille
Date:
I gather from rtfm that it is typical to set up partitions so that the
"master" table has no records.  But from my understanding of
partitions and doing some tests, I don't see any reason that has to
be.  So I'm wondering if I'm missing some subtle (or not so subtle)
point about partitions?  I'd like to have the master table contain all
my records except those that have very specific (and unique) criteria:

CREATE TABLE master (
   master_pk serial NOT NULL,
   myint          integer);

CREATE TABLE master_1 (
   CHECK (myint =1)
) INHERITS (master);


INSERT INTO master (myint) VALUES (2);
INSERT INTO master (myint) VALUES (3);
INSERT INTO master_1 (myint) VALUES (1);

Is there anything wrong with this?  It seems to work well but I am
concerned that I may be missing something since the docs say "<the
master> will contain no data".

Thanks,
Bob Gobeille
bobg@fossology.org

Re: smart or dumb partition?

From
Greg Stark
Date:
On Sat, Aug 8, 2009 at 12:27 AM, Bob Gobeille<bob.gobeille@hp.com> wrote:
> I gather from rtfm that it is typical to set up partitions so that the
> "master" table has no records.  But from my understanding of partitions and
> doing some tests, I don't see any reason that has to be.  So I'm wondering
> if I'm missing some subtle (or not so subtle) point about partitions?

It's purely a convenience issue. Any child partition can be removed
later, The parent will be a pain if you ever want to remove it from
the partitioning structure.

--
greg
http://mit.edu/~gsstark/resume.pdf

Re: smart or dumb partition?

From
Bob Gobeille
Date:
On Aug 7, 2009, at 5:44 PM, Greg Stark wrote:

> On Sat, Aug 8, 2009 at 12:27 AM, Bob Gobeille<bob.gobeille@hp.com>
> wrote:
>> I gather from rtfm that it is typical to set up partitions so that
>> the
>> "master" table has no records.  But from my understanding of
>> partitions and
>> doing some tests, I don't see any reason that has to be.  So I'm
>> wondering
>> if I'm missing some subtle (or not so subtle) point about partitions?
>
> It's purely a convenience issue. Any child partition can be removed
> later, The parent will be a pain if you ever want to remove it from
> the partitioning structure.

Cool.  In my case this won't be an issue.   My app loads in archives
(.tar, .iso, etc) and stores the contained  file hierarchies in the db
(organized by the archive).  So if an archive only has a few thousand
files, I'll just save those few thousand records in the master table.
But if the archive has millions of files (some distro iso's have ~7M
files), I want to store them in their own partition.

Many thanks for the confirmation!

Bob Gobeille
bobg@fossology.org