Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: too many loops while running migrations #618

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ do $$

perform pg_notify('migrations-{{ .Schema }}', 'init: ' || _count);

for i in 0.._count by _batch_size loop
for i in 0.._count-1 by _batch_size loop
-- disable triggers
set session_replication_role = replica;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ do $$
) moves
group by transactions_id;

perform pg_notify('migrations-{{ .Schema }}', 'init: ' || (select count(*) from moves_view));

create index moves_view_idx on moves_view(transactions_id);

if (select count(*) from moves_view) = 0 then
return;
end if;

perform pg_notify('migrations-{{ .Schema }}', 'init: ' || (select count(*) from moves_view));

-- disable triggers
set session_replication_role = replica;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ do $$

raise info '_count: %', _count;

for i in 0.._count by _batch_size loop
for i in 0.._count-1 by _batch_size loop
with _rows as (
select *
from tmp_volumes
Expand Down
Loading