I'm in the process of redesigning/programming a web site of mine in order to take advantage of mod_perl and basically to clean up 3yr+ old kludges now that I know what I'm doing. I've got standard DBI through Mysql, and much of the functionality of the site is searching, producing the output listing, and go from there. Certainly close to a no-brainer.

Now, reading through a recent entry at perl.com on the new Template module, I got to thinking how I may be able to take advantage of this: I certainly could use the ability to use templates to produce various results of the DBI output that I'm getting. However, I'm concerned about speed -- with preliminary scripts running under a mod_perl-enabled virtual host of apache, I seem to be getting no speed benefit, yet. Mind you, two possible slow effects are occuring: I'm using fetchrow_hashref to get the values out from the DBI call, which might have some overhead, and after getting the row data, I do additional processing (more DBI or file reading) for supplimentary stuff. And furthermore, some of the formats for the Templates that I have planned will not use all this data. The data is simple rows, no complex data structures outside a few join'ed arrays.

In other words, I have a tradeoff between a concise and modular function that does the results display but runs slow, and to use several different functions for each list type but most likely a benefit in speed. I'd rather avoid the latter case, but I'm finding right now that even with queries of 5 results, the results take a long time to process. Is Template just not the right tool here, and should I fall back on just using something similar to here documents for each row?


In reply to Speed of Template by Masem

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.