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.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium