Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: how do you label and cache your database queries?

by perrin (Chancellor)
on Sep 01, 2001 at 22:34 UTC ( [id://109665]=note: print w/replies, xml ) Need Help??


in reply to how do you label and cache your database queries?

I don't agree about most production systems using stored procedures or timed jobs for all updates. I've never seen a system that did that, although I've often heard DBAs wish that things were done with PL/SQL. I think it's better to avoid stored procedures as much as possible, but that's a whole different topic.

In my systems, I write Perl classes for each of the data objects I'll be manipulating. These classes handle their own caching.

For example, if I'm building a store and I manipulate data for products, I would make a Product class with load() and save() methods. I'd pass an ID to load. The load() method can then check the cache and go to the database if the object I want is not cached. If it does go to the database, it puts the retrieved data in the cache for future use. I would use the object ID and some constant string denoting the object type as my key in the cache.

It would be very easy to build this kind of thing using SPOPS, and some other tools like Alzabo already do it. My homegrown approach used SQL statements coded in the classes themselves rather than trying to auto-generate them.

Replies are listed 'Best First'.
Re: Re: how do you label and cache your database queries?
by dthacker (Deacon) on Sep 02, 2001 at 17:07 UTC
    I'm very green at OO perl, so I can't address the main topic . I would like to provide some perspective from the DBA side.

    In an OLTP database, stored procedures, and triggers have to be very carefully done, or they can cause more performance problems than they solve. SP's and triggers can also cause a lot of headaches when the database is being replicated.

    As DBA,I ask my perl folks to optimize their SQL and tell me the end requirement for delivery of the info. I'll opt tune indexes if needed and load balance large batch jobs to minimize impact on response time.

    We now return you to princepawn's original topic...

    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found