Optimising your SQL

So far we've looked at the basics of optimisation, and also went into quite some depth regarding how to make your PHP scripts run faster. However, where's the point in making your scripts run faster if the database that drives them crawls? Optimising your SQL so that it runs faster is equally important! This is a big area, so you are strongly advised to read up on the suggestions given here to see whether they will work in your given situation.

There are three basic routes to take when it comes to optimising your SQL: change your queries, change your table schema, or change your server configuration. We'll be looking at all three, starting with queries.

One of the many advantages to SQL is that it is a true fourth-generation language - you tell it what you want, and it does all the hard work for you. As such, the actual /implementation/ of your query requests is left entirely down to your database server, which means it might not necessarily be doing things in the most optimised way. In order to reach the largest audience, I've covered MySQL techniques here, but many of the same rules will apply elsewhere.


Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Prioritise your data >>

Previous chapter: Make sure you optimize Apache

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.