Skip to content

Use a temporary table to update scheduler metrics

When using insert into <...> select <...>, PostgreSQL disables parallel querying. Under some circumstances (in our large production database), this makes updating the scheduler metrics take a (very) long time.

Parallel querying is allowed for create table <...> as select <...>, and doing so restores the small(er) runtimes for this query (15 minutes instead of multiple hours). To use that, we have to turn the function into plpgsql instead of plain sql.

Related to swh/infra/sysadm-environment#3785 (closed)

Test Plan

Poked at the function in production until the runtime came back to a more sensible value. No existing tests are regressing.


Migrated from D6812 (view on Phabricator)

Merge request reports