mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 14:02:55 +00:00
Before, compute_ctl didn't have a good registry for what command would run when, depending exclusively on sync code to apply changes. When users have many databases/roles to manage, this step can take a substantial amount of time, breaking assumptions about low (re)start times in other systems. This commit reduces the time compute_ctl takes to restart when changes must be applied, by making all commands more or less blind writes, and applying these commands in an asynchronous context, only waiting for completion once we know the commands have all been sent. Additionally, this reduces time spent by batching per-database operations where previously we would create a new SQL connection for every user-database operation we planned to execute.
13 lines
342 B
SQL
13 lines
342 B
SQL
DO $$
|
|
DECLARE
|
|
query varchar;
|
|
BEGIN
|
|
FOR query IN SELECT 'ALTER FUNCTION '||nsp.nspname||'.'||p.proname||'('||pg_get_function_identity_arguments(p.oid)||') OWNER TO {db_owner};'
|
|
FROM pg_proc p
|
|
JOIN pg_namespace nsp ON p.pronamespace = nsp.oid
|
|
WHERE nsp.nspname = 'anon' LOOP
|
|
EXECUTE query;
|
|
END LOOP;
|
|
END
|
|
$$;
|