Fix Slow ActiveAdmin Index Pages With Large Datasets by Hiding Filters

As our app grows, sometimes we have to refactor our admin interfaces too

Fatos Morina
Nov 17, 2019 · 2 min read
Image for post
Image for post
Photo by Lukas Blazek on Unsplash

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.

Better Programming

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store