Scott Taylor posted a very detailed write up about understanding MySQL in WordPress. Something I personally think every single WordPress developer – be it plugins or themes – ought to have a deep understanding of. Not just know of it’s existence. In Scott’s words:
You would be surprised how many people I have interviewed for a job that think their PHP chops are great, but their MySQL, not so much. Many great WordPress developers I know have said the same thing. Not cool. Bad SQL can bring down your site! Forget crazy scaling challenges, basic WP Query usage can bring your site down if you aren’t careful. WordPress is a framework that provides you with a lot out of the box, but you are still going to end up writing a bunch of your own PHP to make it work the way you want. The same should be true, but often isn’t, for SQL queries.