In dashboard.rb, RailsAdmin does the following for every table by default:
@most_recent_changes[t.model.name] =
t.first(sort: "#{t.table_name}.updated_at").try(:updated_at)
This is an ENORMOUSLY expensive call for any table that is not indexed on updated_at. For example, on my app:
coderpad-rails=# EXPLAIN SELECT "pads".* FROM "pads" ORDER BY pads.updated_at desc LIMIT 1;
QUERY PLAN
----------------------------------------------------------------------------
Limit (cost=25411.89..25411.89 rows=1 width=1203)
-> Sort (cost=25411.89..25811.53 rows=159859 width=1203)
Sort Key: updated_at
-> Seq Scan on pads (cost=0.00..24612.59 rows=159859 width=1203)
(4 rows)
This is occasionally causing complete HTTP timeouts in my application. I don't want to add an index just to service this dashboard, either. I'm going to turn off statistics entirely because there doesn't seem to be a way to disable just this behavior, but I'd recommend either adding a flag or just showing something much easier, like the created_at time on the last row in the table.
In
dashboard.rb, RailsAdmin does the following for every table by default:This is an ENORMOUSLY expensive call for any table that is not indexed on
updated_at. For example, on my app:This is occasionally causing complete HTTP timeouts in my application. I don't want to add an index just to service this dashboard, either. I'm going to turn off statistics entirely because there doesn't seem to be a way to disable just this behavior, but I'd recommend either adding a flag or just showing something much easier, like the
created_attime on the last row in the table.