Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK0TE-0006lO-TS for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 12:28:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gK0TD-0007vA-FV for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 12:28:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK0TD-0007uv-5C for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 12:28:35 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gK0TA-00056a-E2 for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 12:28:34 +0000 Received: by mail-oi1-x234.google.com with SMTP id x63-v6so6806343oix.9 for ; Tue, 06 Nov 2018 04:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=NoClgO6VOxrk9fX+9OtXywkZY/jnEbE4oSdhq+hGLkA=; b=rimJHWi11h7iNycShBXKBIVvPSNUZRuYFEiOS+o2f9Pjo7meTE12uIcx2GxcAHxzOC dAaAb7IQlxaGmH/iOrXZP+gYmYgDLUvZYMLUp5y8OqNH/SCxBaWffhjvZGNmcmTRlcye xApsJLpR9r7jq8O9WZITtGZRew4mcBshxsEopi6Mjebt8I8VdFBr1pNApuVKpDlg3VzB dnjEiCY7NiPR2yX1aBq9MTlAYef0xAsEApAAGOIyJBIQw8SJdj8KNUEV/I/pSTxaOjuB ICsoDwHowGsvhX66r/fPQAzlSacnpcKBkJz+5ptyxqlvJF8SXixat98G2Uuh2lsEXDxB pOow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=NoClgO6VOxrk9fX+9OtXywkZY/jnEbE4oSdhq+hGLkA=; b=jkmj8tkphyxeMQNbs+f/OMQ5pTe+dnUpQigS4QMqG8AeRIjx93L+fgJf+jucwo3qq+ WGq5L1ZVFzLyJM/uqk710rGP3UyGQ/raF7UTiO3xrr59llJM/7hI7xSk8hk9UoV4h72b 8q7lZIyTgpWv4ePerW8jz9Nc5Vy18R408gb64yrSq4qOLXW4icHHgE0Gne0XhvGfT1/j wdTzbblcIS0uGY2jOvBhSO/0uTesqJaafa20B7ZY6qnhNfGyxxJGApz7VMMjVTXCdNYF HT8WmlSlRSfECt4OSPs5/GOYIxTiEmBDCKkpntUFV8jkCcEZb1FTkcRTMPpIwiyZUab9 w52w== X-Gm-Message-State: AGRZ1gIF4dHya8ASep857vuTWhAIcR361i31Bnz4Qf1+egLlKa7w7BPS XqdEMGLMV78p0RtCB6llGLtsBgX2 X-Google-Smtp-Source: AJdET5c+Os0A+KxqaHPMKaqFy2QAMAxXeS1re3onb7zwCHKYrsShyF4CvF7oLI6J5r7NU8Pbzp2LMg== X-Received: by 2002:aca:3809:: with SMTP id f9-v6mr15601279oia.224.1541507308642; Tue, 06 Nov 2018 04:28:28 -0800 (PST) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id 80sm15285759oti.37.2018.11.06.04.28.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 04:28:27 -0800 (PST) Subject: Re: CREATE OR REPLACE FUNCTION statement just sitting there To: pgsql-general@lists.postgresql.org References: <20181106113429.eckik5dtmspck4lz@alvherre.pgsql> From: Ron Message-ID: Date: Tue, 6 Nov 2018 06:28:26 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181106113429.eckik5dtmspck4lz@alvherre.pgsql> Content-Type: multipart/alternative; boundary="------------A09C580B3DFE66B102418D11" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------A09C580B3DFE66B102418D11 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 11/06/2018 05:34 AM, Alvaro Herrera wrote: > On 2018-Nov-05, Ron wrote: > >> That (plus pg_locks)  is the heart of the "list all blocking queries" >> statement I copied from https://wiki.postgresql.org/wiki/Lock_Monitoring. > On that page there's a note about 9.6. Did you see the referenced > commit > https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52f5d578d6c29bf254e93c69043b817d4047ca67 > ? Maybe see about using the "pg_blocking_pids(int) returns int[]" > function instead. I did see it, but the https://wiki.postgresql.org/wiki/Lock_Monitoring query seems to work (seeing that it regularly shows locks). Is this query from https://stackoverflow.com/a/43363536/1543618 adequate to the task? |selectpid,usename,pg_blocking_pids(pid)asblocked_by,query asblocked_query frompg_stat_activity wherecardinality(pg_blocking_pids(pid))>0;| -- Angular momentum makes the world go 'round. --------------A09C580B3DFE66B102418D11 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 11/06/2018 05:34 AM, Alvaro Herrera wrote:
On 2018-Nov-05, Ron wrote:

That (plus pg_locks)  is the heart of the "list all blocking queries"
statement I copied from https://wiki.postgresql.org/wiki/Lock_Monitoring.
On that page there's a note about 9.6.  Did you see the referenced
commit
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=52f5d578d6c29bf254e93c69043b817d4047ca67
?  Maybe see about using the "pg_blocking_pids(int) returns int[]"
function instead.

I did see it, but the https://wiki.postgresql.org/wiki/Lock_Monitoring query seems to work (seeing that it regularly shows locks).

Is this query from https://stackoverflow.com/a/43363536/1543618  adequate to the task?
select pid, 
       usename, 
       pg_blocking_pids(pid) as blocked_by, 
       query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;


--
Angular momentum makes the world go 'round.
--------------A09C580B3DFE66B102418D11--