Asking this after searching around without any solution:
I create a simple materialized view (in practice, I have a few of them).
pg_dumpto backup the database.
pg_dumpis running, I try to refresh the view using
REFRESH MATERIALIZED VIEW.
REFRESHstatement hangs (remains 'active') as long as
pg_dumpis active (this makes things even worse as while the view hangs on
REFRESH, I cannot
SELECTfrom it as well).
My question is: how can I
REFRESH materialized views while performing a dump?
I don't mind excluding the data of the view from the dump if this will help, I don't need to save the data. But I also wouldn't want to complicate my dump command to an unreasonable amount just to make this work.
Thanks in advance!
Complete list of commands:
psql my_db -c "CREATE MATERIALIZED VIEW my_view AS (SELECT * FROM my_table);" pg_dump -Fc my_db (in a different process, while pg_dump is active:) psql my_db -c "REFRESH MATERIALIZED VIEW my_view;"