Art of SQL

Thu Aug 31 13:20:00 2006

The Art of SQL

A year ago I didn't know much about SQL. I knew that the keywords were INSERT, UPDATE, SELECT and DELETE. I knew that indexes made things faster and I had been taught the theory behind what makes something 1st, 2nd, 3rd normal form, but that is it.

I saw that some of our sites were slow and that was due to bad SQL design and lack of indexes. I soon learned enough SQL that, when combined with a bit of a guess about how I would execute the queries if I was a computer, I was able to make the queries faster. Since then I have been more and more interested in making sure that queries are as efficient as possible, sadly something that can be very important, but is difficult to test in the early stages of an application's life as there isn't a lot of data in the database so slow approaches taken by the query analyser are not noticable.

Recently I have been reading ' The Art of SQL ' by Stéphane Faroul . This is a treatment of the idea of optimising your databases from the theory side, just the way that I have been taught about everything else. It doesn't really tell you what to do, but it explains why it all happens the way it does, and suggests mays of approaching the common problems. I have found it easy to read and not at all drudgery. It isn't really a reference book, more of a book that you read from cover to cover. You may, however, wish to return to it from time to time when you encounter a problem that was discussed in the book.