I'm using pgAdmin III v1.22.1 on Windows 7 to connect to a PostgreSQL server version 9.4.8 on Red Hat.
We have scripts to REFRESH MATERIALIZED VIEWS
during the night.
When they are refreshing, I can't connect to pgAdmin III. It just freezes. It seems that it tries to query some locked objects.
When the materialized views finishes refreshing, I am then able to log in via pgAdmin.
When the REFRESH MATERIALIZED VIEW my_view
is done, the above query is run and pgAdmin unfreezes.
Is there a way to prevent pgAdmin from freezing when MATERIALIZED VIEWS
are refreshing?
Best Answer
I seems that it's a known bug. I'm answering to my own question with this workaround.
If you use PostgreSQL 9.4+, one workaround is to use
REFRESH MATERIALIZED VIEW CONCURRENTLY
.From PostgreSQL's manual:
You just need to add an
UNIQUE INDEX
to your materialized view and to refresh itCONCURRENTLY
:But it does not prevent other users from running long refreshes which hangs my pgAdmin.