Automatically generate an index for the generated columns for inherited objects

Tested with Rails 4.1 and MySQL, and did an EXPLAIN.