Crazy Queries

So as anyone who reads this blog consistently knows, I’ve implemented a new monitoring system on our server.  I mentioned that I still don’t know all I can do with it, or what half of it means, but I’ve found out some interesting things.  One thing of note that floored me was how one page of an administration was making over 2,000 individual queries to the database.  I could not help but laugh at that.  This was slowing down the page processing quite a bit, after all, if you had to go back and forth 2,000 times, even say, from the left side of your desk to the right, it would take a pretty long time.  Now computers are faster, but we measure that in milliseconds, and when you have to sit and wait for a page to load, that’s measured in your life draining away, and we all know how sensitive we are about that.  No one wants to wait for a page to load.  I’m one of those website rage people who, if I have to wait for the page to load, or if I have to install something, I will just as soon go elsewhere and never come back.  If I have to use the site, then of course I sit and stew and mutter things the whole time while counting the seconds of time wasted waiting.

Anyway, so to combat my 2,000 database queries, since I was pulling a lot of information from tables that won’t change very often, I set up a bit of a cached query.  It’s not cached in the Coldfusion sense, it’s instead in the session sense.  I pull in the data into a session variable and basically hang on to that query and then do a ‘query of queries’ whenever I need the info.  It’s something I’d normally do, but for some reason on this site I did not.