Jack James
Jack James

Reputation: 5372

Is it worth caching simple MySQL results

I have a PHP script that runs very simple queries on a MySQL database (up to a maximum of 25 times per page). Is it going to be worth caching the results (e.g. using APC), or is the performance difference likely to be negligible?

Upvotes: 2

Views: 137

Answers (1)

Ray
Ray

Reputation: 41448

Caching is just about always worth it. Pulling it from APC's in memory user cache vs. establishing a db connection and running queries is a massive difference--especially if you're doing 25 queries on a page!

The benefits will compound:

  1. Pulling from memory you'll serve up requests faster by requiring less overhead
  2. You'll free up db connections
  3. You'll free up apache processes faster
  4. All of which will help server up request faster...

Upvotes: 4

Related Questions