February 2020
Intermediate to advanced
734 pages
38h 13m
English
We begin the process by getting a list of every process ID, duration, and query currently running for longer than 2 seconds. Though 2 seconds is arbitrary, it helps filter out short and fast queries that we aren't interested in pursuing. If we examine the queries listed in these results, we may decide that one or more need to be canceled or disconnected. The results should resemble this output:

If this is the case, the pid column conveys important information necessary to target the client connection. We begin by invoking pg_cancel_backend in an attempt to terminate the currently running query. Often, this is enough to clear ...
Read now
Unlock full access