I have a simple table inherance, with an upper class GeneralElement. A
class that inherits is Activity:
class Activity < GeneralElement
...
end
The GeneralElement table is very big (about 2.000.000 rows!). Other
classes that inherit from GeneralElement return queries very fast, but
Activity.last is very slow. I have added indexes to id and type, but it
has no effect. What can I do?
You may want to grab the query that Activity.last is using, and try
running it through 'EXPLAIN' to see what it's looking for. Have you
defined an order (via default_scope, for instance) on Activity? You
might need to have an index on that field together with 'type' to get
right behavior.