Fix Slow ActiveAdmin Index Pages With Large Datasets by Hiding Filters
As our app grows, sometimes we have to refactor our admin interfaces too
I was recently using Active Admin and came up with a particular case where the index page for a particular resource was loading really slowly. After trying to search up and down, trying to figure out what was the issue, I finally found that the issue was with a filter.
To explain it a little bit more clearly, let us suppose that we have a particular case where you have a project in which a client has many transactions and we have hundreds of thousands of transactions.
Now, due to the fact that we have a client with so many transactions, getting all these records each time you visit the index page of the client takes a lot of time. On the index page, you may have many filters, where a filter can be used to filter clients based on the transactions.
Due to the fact that we have so many records, we can simply hide this filter, so that we are no longer trying to filter clients based on the transactions. To do that, we can simply write:
Now we no longer have to wait so long for the page of clients to load.
You still can filter transactions for different clients by having a
client filter inside the transactions’ index page.
You have considerably fewer clients and the transactions of results are also paginated, so this should still give you a way of filtering the results without having to compromise with the loss of this filter.
I hope that helps.