This is not a normal situation but I am working with a partitioned table and would like to route selects against the parent table to the partitions directly (in order to avoid the db planner requiring access to the other tables for constraint exclusion reasons.

Ideally primary key would have a field in a multi-column pkey, something like "partion_id" and the table name would be something like "mytable_" . $self->partition_id.

What is the best way to accomplish this?

Edit: Selecting on the main table works from an application perspective but it has unpleasant effects on database administration tasks (ones which lock any underlying tables block *all* queries on the parent table) and one can't just use a view because the view doesn't get to decide without doing exactly what the current query is doing (a union through all with constraint exclusion). Subclassing isn't an option because this is a component of a complex system and subclassing for every partition will get ridiculous quickly. So I am looking to see if there is a way I can tie the table to the object instead of the package.


In reply to Dynamic table names and DBIx::Class by einhverfr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.