Concurrent refreshes of materialized views don't have a record in pg_stat_activity
, other than the initial (~immediately completing) query to start them.
Is there some other way to obtain the PID, in order to perform pg_terminate_backend(pid)
?
killmaterialized-viewpostgresqlpostgresql-10
Concurrent refreshes of materialized views don't have a record in pg_stat_activity
, other than the initial (~immediately completing) query to start them.
Is there some other way to obtain the PID, in order to perform pg_terminate_backend(pid)
?
Best Answer
That is not true.
That statement does not complete immediately, but hangs until the materialized view is refreshed.
Then, while the statement is running, in another session:
The statement is canceled. In the first session, I see:
Perhaps you are confused by the fact that the
query
column inpg_stat_activity
does not only show the current query, but the latest query that was run in that session. So if thestate
isidle
, then the statement is done and the materialized view is already refreshed. Then of course canceling the query has no effect.