in reply to mySQL hits or Storable retrieves?

Let me re-state your question: "What's a good way to efficiently load a complex but infrequently changing data structure that I want to display in my mod_perl application?"

MySQL is fast enough for most uses like this, but if you have an unusual amount of traffic or a poorly designed schema and your data does not need to be 100% up-to-date, caching is tremendously helpful. The approach you described will work just fine. I would suggest you use Cache::Cache or MLDBM::Sync instead of rolling your own filesystem database though. The biggest problem with this approach is that your data set may become too large to efficiently regenerate all of it every 5 minutes.

I used a load-on-demand approach with caching for the eToys.com product data. This avoids problems stemming from a large data set, but does result in a slower load time for the first user. Here's a description:

You can vary how much your cached data gets out of sync by adjusting the time-to-live for objects in the cache.

Caching is a big subject, and there are lots of tricks you can use (lazy reloading, pre-filling the cache with hot objects, etc.).

Replies are listed 'Best First'.
Re: Re: mySQL hits or Storable retrieves?
by Hero Zzyzzx (Curate) on Oct 02, 2001 at 18:56 UTC

    Wow. Thanks for the very helpful response. Part of my problem here is I think I've normalized my data too much (if that's possible), it's split across so many tables that writing the SQL properly is getting beyond me.

    Basically, I'm at the point where I need to run the entire universe of records through a set of filters, akin to:

    1. What documents are in this category/subcategory?
    2. Is the user public, staff, probono attorney, admin, etc.?
    3. What organization is this user from, and what docs are specifically excluded from this organization at this access level?

    So, it would be so much easier if I didn't have all this conditional crap. I'd probably do it with one SQL join, but I can't here, I need more than one statement (at least in my head) and I think caching the results is the only way I'm going to get a useable, fast suite of sites.

    -Any sufficiently advanced technology is
    indistinguishable from doubletalk.

      Creating a few views might help you to get your head around the queries...

      A database view is a sort of virtual table. You create it with a SELECT statement and then access it like a regular table.

      CREATE VIEW view_red_cross_docs AS SELECT <code here> CREATE VIEW view_pro_bono_docs AS SELECT <code here> SELECT <stuff> FROM <joined views>


      email: mandog
      Object-level security? It sounds like you want SPOPS, or even the app server built on top of it, OpenInteract. It has hooks to add caching as well.