【问题标题】:What generates the first ActiveAdmin COUNT query?什么会生成第一个 ActiveAdmin COUNT 查询?
【发布时间】:2015-12-17 21:07:02
【问题描述】:

我的 ActiveAdmin rails 查询日志的开头如下所示:

Started GET "/things" for 127.0.0.1 at 2015-12-17 15:43:30 -0500
Processing by ThingsController#index as HTML
AdminUser Load (57.1ms)  SELECT  `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 1  ORDER BY `admin_users`.`id` ASC LIMIT 1
(58.1ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM `things` WHERE `things`.`retired_at` IS NULL AND `things`.`errored_at` IS NULL LIMIT 30 OFFSET 0) subquery_for_count
CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM `things` WHERE `things`.`retired_at` IS NULL AND `things`.`errored_at` IS NULL LIMIT 30 OFFSET 0) subquery_for_count
CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM `things` WHERE `things`.`retired_at` IS NULL AND `things`.`errored_at` IS NULL LIMIT 30 OFFSET 0) subquery_for_count
CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM `things` WHERE `things`.`retired_at` IS NULL AND `things`.`errored_at` IS NULL LIMIT 30 OFFSET 0) subquery_for_count

ActiveAdmin 或其依赖项中产生 58.1ms SELECT COUNT ... subquery_for_count 的机制和文件是什么?

【问题讨论】:

    标签: ruby-on-rails activerecord activeadmin arel kaminari


    【解决方案1】:

    您可以参考以下网址:documentation

    可以通过以下方式减少计数查询:

    index pagination_total: false do
        # ...
    end
    

    希望对你有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-03
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多