Re:How to assert that your SQL does not do full table scans
by mullr on Friday March 26, 2010 @11:12AM
(#1221187)
But for those cases where you are just pulling a row or two, this is a nice technique. It hints at something more interesting, I think.
Fundamentally it wants to be an assertion against the schema. It would be better to be able to ask the database about the worst-case complexity of a particular query, then write assertions against that. (I don't think this is the same as 'explain', it's more like 'explain as if' with some structure behind it)
Something like: assertEqual( O(log(n)), schema.worstCaseComplexityOf('SELECT text FROM response WHERE questionId = 27 AND participantId = 38'))
Even better would be a schema language that lets you build in these assertions directly. This is really something you should be thinking about while designing the schema, after all.
Fundamentally it wants to be an assertion against the schema. It would be better to be able to ask the database about the worst-case complexity of a particular query, then write assertions against that. (I don't think this is the same as 'explain', it's more like 'explain as if' with some structure behind it)
Something like: assertEqual( O(log(n)), schema.worstCaseComplexityOf('SELECT text FROM response WHERE questionId = 27 AND participantId = 38'))
Even better would be a schema language that lets you build in these assertions directly. This is really something you should be thinking about while designing the schema, after all.