Explain COUNT query with ActiveRecord
Here's a form that generates the exact same SQL query, but returns a Relation to call explain
on:
Post.select('count(*)').explain
Both generate the SQL
SELECT COUNT(*) FROM `posts`
...so the query plan should be the same.