checking the schema_migrations table queries
This query appears to be run ~1300 times per second:
SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','m') -- (r)elation/table, (v)iew, (m)aterialized view
AND c.relname = 'schema_migrations'
AND n.nspname = ANY (current_schemas(false));
Looking through the rails code, this looks like it might be a "table_exists?" call happening, though it's not obvious to me where such a call would be getting made for the 'schema_migrations' table.
Note that the total number of queries/s is only around 10 000, so this query appears to be accounting for >10% of the queries (and, likely, the transactions) on the primary database.