标签: sql ruby-on-rails activerecord postgresql-10
我遇到this answer是为了加快查询速度,并说要使用
SELECT COUNT(*) FROM (SELECT DISTINCT column_name FROM table_name) AS temp;
代替
COUNT(DISTINCT column_name)
人们将如何在ActiveRecord中编写此更改(不只是作为sql语句编写)?