Skip to content

Disable COUNT(*) for filtered collections #6492

@kceb

Description

@kceb

Did you find a bug?

I'm using pagination_total false on the index collection, which works fine and as expected. However, I'm noticing in the SQL debug logs that when I filter a collection (by user_id), it is still doing a SELECT COUNT(*) FROM (SELECT 1 AS one FROM "large_table" WHERE "large_table"."user_id" = 123 ORDER BY "large_table"."id" desc LIMIT $1 OFFSET $2) subquery_for_count.

Is there a way to disable this for filters? I have an extremely large table and it is causing my app to timeout.

I'm just using the default filter method on my activeadmin model

Expected behavior

Filtering large tables should not run an expensive COUNT(*) or ORDER BY (even if it is using limit and offset)

Actual behavior

Request times out

How to reproduce

Have an extremely large table and filter on an indexed column like user_id. Expect it to be relatively performant and not run things like COUNT(*) unnecessarily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions