I spoke at Montreal on Rails on Tuesday night. I think I had 5
slides, but spoke for about 45 minutes (so there's no point in
uploading them). For those that missed it (or couldn't take notes
fast enough), here's a transcript of the examples I showed with
the world
database:
# take a look at this query. To start with, we have no indexes used: EXPLAIN SELECT Name FROM Country WHERE Continent = 'Asia' AND population > 5000000 ORDER BY Name; # First let's look at an index on population ALTER TABLE Country ADD INDEX p (Population); # is that index effective? EXPLAIN SELECT Name FROM Country WHERE Continent = 'Asia' AND population > 5000000 ORDER BY Name; # no it wasn't. what happens if we modify the query just slightly: EXPLAIN SELECT Name FROM Country WHERE Continent = 'Asia' AND population > 50000000 ORDER BY Name; # time for the next index: ALTER TABLE Country ADD INDEX c …[Read more]