Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

FOLLOWUP

by Masem (Monsignor)
on Feb 14, 2001 at 23:34 UTC ( [id://58421]=note: print w/replies, xml ) Need Help??


in reply to Speed of Template

As I've been using some of the ideas here and on the web for what I'm doing, I'd thought I'd share them here.

First, I did find that SQL queries were slowing me down : I was trying to be cute with INNER JOINS, but after recognizing that key searches that I'd want to do would require 2 or 3 inner joins to do it, and this ate up alot of time. I figured that most of the data that the frequent searches will be done with is static except when *I* change it (infrequent or as necessary), that I'd create a 'cached' column of data of what I'd normally get out of the JOINs, usually as a /;/ list, so that I can then use REGEXP to get the data that I need instead. I can then use secondary SQL calls to get any additional data out of the table. It's arguable that these secondary calls may increase runtime, but it increases the modularity of the CGI/perl stuff, since I use similar calls at other non-searching parts of the site. (As another optimization point, I would think that if I kept around a global variable for the $sth for these utility functions, since the query format doesn't change, only one placeholder, I'd get a bit more optimization... must try that tonight... :D)

Template is *wonderful* to work with. It allows me to have minimal HTML code, even through CGI.pm, in the perl code, and thus provides yet another degree of model-controller-view. And yes, once I worked out the SQL problems, it was sufficient fast. Plus, Template has enough logic possibilities built into it that I can use more general results as outputs from my modular perl functions (refs to arrays and hashes as opposed to strings) and decide how to deal with them when I tighten down the presentation issues of my site. For example, one of the results of the faux JOIN above is a list of id number, each which, in a separate table, has a name; these can lead to individual pages which can be linked too, however, I may not always want to link to such in my code. I *could* write two functions in perl, one for the non-linked list, one for the linked list; I could supply the extra parameter in the function and handle it as such, but I think the most generic way to go is to return a hash, as I can still grab the list of names via a join(values()). But since Template can iterate through hashes, I'll just pass it to the template file, and then handle it there. Oh, but the possibilities..!

I'm glad that the suggestions here made me stick with it -- the time of development right now is much faster than if I stuck to only perl and CGI for code generation. I'd be happy to share specific details of my experiences if anyone is in a similar position.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://58421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-20 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found