Skip to main content

Posts

Showing posts from February, 2014

Unittesting your indexes

During FOSDEM PGDay I watched the "Indexes: The neglected performance all-rounder" talk by Markus Winand. Both his talk and the "SQL Performance Explained" book (which is also available online ) are great. The conclusion of the talk is that we should put more effort in carefully designing indexes. But how can we make sure the indexes are really used now and in the future? We need to write some tests for it. So I wrote a small Python script to test index usage per query. This uses the JSON explain format available in MySQL 5.6. It's just a proof-of-concept so don't expect too much of it yet (but please sent pull requests!). A short example: #!/usr/bin/python3 import indextest class tester(indextest.IndexTester): def __init__(self): dbparams = { 'user': 'msandbox', 'password': 'msandbox', 'host': 'localhost', 'port': ...