by Phlip

To ensure your test cases call efficient MySQL

  def test_my_case
    assert_efficient_sql do

      # just wrap them in this block!


The assertion intercepts and copies out your MySQL SELECT statements, then calls EXPLAIN on each one, and inspects the results for common problems.

The goal is test cases that resist database pessimization, even as you change your data relations, to add new features. If you run your tests after every few changes, you can easily detect which change broke your database's indices and relations.

This article is a reference for this assertion's options. The techniques should be ported to any database with an EXPLAIN or similar system.


Shanti Braford
2008-01-14 10:33:41
This rocks.