Thursday 7 June 2007

Please explain indexing...

So the DMT class is over but I figure I'm gonna do a few more blog posts - I just might pass this subject if I blog on the things I thought were interesting 10-12 weeks ago... but as for this blog, it's about something I just learnt (this betrays the status of my 'System Build')... indexing in MySQL, what a neat function. Now I understand how clever uses of the index feature can speed up data retrieval in a database.

Thank you Ian Gilfillan for explaining this in "Optimizing MySQL: Queries and Indexes".

Basically, the index feature allows the quick look up of data. For example, rather than scouring an entire databases for someone's name, if you index the 'firstname' and 'lastname' columns of your 'contact' table, when you run a name query, these columns get queried first - so rather than looking through your entire database until your query gets lucky, it looks straight at where the data sits.

Ian also covers the EXPLAIN query in MySQL, which enables you to QA just how efficiently you have used the index feature. I know this is a bit late for a lot of my fellow students to take advantage of, but it's a handy tip nonetheless.

No comments: