dear monkz.

up to this day i have been able to struggle myself through that behemoth that is called Perl, but now i am in need of assistance.

i have inherited a piece of corporate software that makes my eyes bleed and my brain hurt. i am tasked to refactor it (at least there is SOME sanity in this) prior to implement new features. for corporate concerns i cannot post any "real" code. i try to get along with pseudo-code.

the software in question is a Perl module (used in a web-app) that receives three lists. first is a list of "group fields" (like 'username', 'book_id'), second is a list of "value fields" (like 'no_of_book_sales', 'comission_total'), third is an optional list containg filter definitions. the fields may come from up to 4 different tables. it returns the SQL to make a 'sensible' query to our database.

the parameters come from a web fronted that is designed to make it easy for our clients to create user designed queries via browser. depending on the incoming query fields the module decides from which table to select which fields in which order. there are also lots of optimizations and special cases (most of them to ensure a tight search when filtering) which are handled by a nightmarish construction of try catch, if and elseif blocks. not to mention that beast of a dispatch table that is alone capable of getting you 3 grey hairs (per day you work on it).

a very important special case is the "stats" table of which we have 3 instances. "stats_all", "stats_fast", "stats_faster". the last two are condensed (by dropping group fields and summing) versions of stats_all, each about 20%-30% of the size the bigger table. each table has a different duration. the data in stats_all only lasts 3 months, the data in stats_fast 1year and the data in stats_faster lasts (hopefully) for ever.

The current module investigate the "wanted fields" lists and selects the appropriate table to use.

At least, the connections between the source tables are relatively easy to handle. the mentioned "3 tier table" is always leading and there are only left joins.

Honestly, I have no idea how to tackle this. I read about sql-dictionaries, SQL::Abstract (which is unfriendly to nesting anonymous sub queries), and others.

someone got a cluebat for me?


In reply to Inheriting Bullsh!t by alaska.saedelere

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.