checking if a table exists queries
This generic 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)elation/table, (v)iew, (m)aterialized view
AND c.relname = ?
AND n.nspname = ANY (current_schemas(?));
It may be that it's always run with the 'schema_migrations' table (issue https://gitlab.com/gitlab-org/gitlab-ce/issues/33278), or it might be that it's sometimes run with schema_migrations and sometimes (or perhaps extremely frequently?) run with application_settings in a 'table_exists' call from lib/gitlab/current_settings.rb, line 49 (at commit 69e4b27c).