Skip to content

Commit 00e9aa3

Browse files
authored
Update refresh_all.sql
1 parent d2787d5 commit 00e9aa3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

matviews/refresh_all.sql

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
-- it might perform multiple iterations and eventually refreshes
44
-- all matviews (either all w/o data or absolutely all -- it's up to you).
55

6-
-- You can set 'postgres_dba.refresh_matviews_with_data_forced' to TRUE or FALSE in advance, outside of this script.
7-
-- If set to TRUE, it will cause ALL matviews to be refreshed, including those that already
8-
-- contain some data (were initialized / successfully refreshed somewhen in the past).
6+
-- set thos to TRUE here if you need ALL matviews to be refrehsed, not only those that already have been refreshed
97
set postgres_dba.refresh_matviews_with_data = FALSE;
8+
-- alternatively, you can set 'postgres_dba.refresh_matviews_with_data_forced' to TRUE or FALSE in advance, outside of this script.
109

1110
set statement_timeout to 0;
1211
set client_min_messages to info;
@@ -58,14 +57,13 @@ begin
5857
end loop;
5958

6059
iter := iter + 1;
61-
exit when iter > 10 or 0 = (select count(*) from pg_matviews where not ispopulated);
60+
exit when iter > 5 or 0 = (select count(*) from pg_matviews where not ispopulated);
6261
end loop;
6362

64-
raise notice 'Finished! % matview(s) refreshed in % iteration(s). It took %', done_cnt, iter, (clock_timestamp() - now())::text;
63+
raise notice 'Finished! % matviews refreshed in % iteration(s). It took %', done_cnt, (iter - 1), (clock_timestamp() - now())::text;
6564
end;
6665
$$ language plpgsql;
6766

6867
reset postgres_dba.refresh_matviews_with_data;
6968
reset client_min_messages;
7069
reset statement_timeout;
71-

0 commit comments

Comments
 (0)