Finding which WordPress requests are hardest on the database

Everyone says WordPress can handle north of a 100,000 or a million posts, no problem!


Okay, if you have a dedicated database system with enough RAM to hold the entire dataset, then A) that’s cheating, since RDBMSs were created to handle the case where one doesn’t have the requisite memory; and B) I don’t have that luxury right now. I routinely run into lots of performance issues despite a well-tuned LAMP system.

Witness the awesome power of this addition to your functions.php file, inspired by this SO post:

Don’t forget to turn off the SAVEQUERIES define in wp-config.php, or else your disk may fill up rather quickly.