Closed jamie closed 2 years ago
Thank you for this report. It provided a more focused example that helped me understand the issue much better. I have proposed a solution at https://github.com/thoughtbot/administrate/issues/1697#issuecomment-1004606731 PRs welcome :-)
I'm going to close this in favour of #1697.
So this has some overlap with #1697 but...
I'm attempting to make a vanilla admin for a work application, where we have one model with a large number of associated log records, but as time goes on we're starting to see excessively long request times from default-generated screens.
Example app has a fresh rails/administrate install, with two models. Setup steps are in the git commit messages. This gets me the following screen:
with the following queries via rails logs:
Loading all the associated messages when we just need a count is prohibitively slow once the model is of a decent size (even with this small 4-column table, there's a very measurable performance impact I believe due to ActiveRecord object creation). Running ab on a local dev server, so concurrency 1:
All that to say: when generating a count of associated objects, I would expect Administrate to be running a
select count(*)
here for performance.