This question is while postmaster is running your query in the background, how to kill or stop it?

For example, your shell or any frontend may be disconnected due to network issue, you cannot use ctrl-D to kill it but the background postmaster is still running your query. How to kill it?

Andong Zhan

Ответов: 1

Ответы (1)

What I did is first check what are the running processes by

SELECT * FROM pg_stat_activity WHERE state = 'active';

Найдите процесс, который хотите убить, затем введите:

SELECT pg_cancel_backend()

This basically "starts" a request to terminate gracefully, which may be satisfied after some time, though the query comes back immediately.

Если процесс не может быть остановлен, попробуйте:

SELECT pg_terminate_backend()

2022 WebDevInsider