Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhHeG-0004Aa-Sa for pgsql-performance@arkaria.postgresql.org; Thu, 13 May 2021 20:09:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhHeF-00058s-QH for pgsql-performance@arkaria.postgresql.org; Thu, 13 May 2021 20:09:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhHeF-00058c-DE for pgsql-performance@lists.postgresql.org; Thu, 13 May 2021 20:09:31 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lhHeC-0003JQ-Da for pgsql-performance@postgresql.org; Thu, 13 May 2021 20:09:30 +0000 Received: by mail-io1-xd31.google.com with SMTP id a11so26104996ioo.0 for ; Thu, 13 May 2021 13:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2plYszvYYaV5VyZTFwKX0CAJJjAlpZ3o1psFgBE5fwg=; b=sWvdil8xgXnV/sOnYu0yl1xbWJGzn196UR36Z2CNqLcI0kzdz08iSQVQ75DTIPOJnF nWz8Wtk/ss9GoXPD5fusaBK5HPEDaywMglIXe0YcsVPGxsToi0vC+gY7n4n0tey1QVqE muVCPLifsUE317UfE7yY1swGe9yl2o7lze7F7zz+kWMMkNPbFZwSy3SdZQTzANp07TFj ZzMl4eZRGos3oWroDwfiwrpF6aFAqnDpwqlG1MSx3rz5xPyIVb5lLhVzk9ScN1w1Eys3 nchzHC2v0tEdfYRRDV3DSsIMsq8dW9XsqzJbsivk7V6gczjwfpyTCkg05Q2ozhfpO+F/ vCkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2plYszvYYaV5VyZTFwKX0CAJJjAlpZ3o1psFgBE5fwg=; b=b7U+mlyZS5GKORZUk8y132JkMxyvVw57MZvx8Tf3XBALAXjWnewv8ZIQB7rFtnARHo ids2ambnW60sApaKYToUZiJJE6Et//YxbDPLLIG0Q9pjkS+ghW37d1788filHs2TmmdM EH8AiX/pPAyDFCh3/wtIyviaC4uhidXdxPOHSxMrJ4AF2/4HikIuntZT0VptWbfd2p4q qQdfqLbwq5Ie7u7VToLc3nmMbL1iLCAduNzGmiXfPp4elr/1BnbutzAJojdnascSA9vY 9aZAPbHARta2evP8CxEaFsmD4gqATIcmULfATOvtLRgAFcgEej4joButVqC5MQtXAYKT E00g== X-Gm-Message-State: AOAM532ay0GynewL8hx0aMTDhrocXBj1Ptea4xGhmrY6SY37FPfh9tfj HnO8Io+iWN/gj4P55rByip3qAEfSTVlMpw== X-Google-Smtp-Source: ABdhPJxQYpi5qCmbHrQkeKjY3GEojJQWH1CL4GxVZmls/cXsXJXw/+s65N5M8hIHOKOq+fslfSzfbQ== X-Received: by 2002:a05:6638:4a:: with SMTP id a10mr39796987jap.142.1620936567035; Thu, 13 May 2021 13:09:27 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z5sm1857071ilq.68.2021.05.13.13.09.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 May 2021 13:09:26 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id A89CB80094D; Thu, 13 May 2021 15:09:25 -0500 (CDT) Date: Thu, 13 May 2021 15:09:25 -0500 From: Justin Pryzby To: Manoj Kumar Cc: "pgsql-performance@postgresql.org" Subject: Re: PostgreSQL blocked locks query Message-ID: <20210513200925.GL27406@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, May 13, 2021 at 01:54:32PM +0000, Manoj Kumar wrote: > I have query in terms of lock monitoring in PostgreSQL where I am not able to find a way to figure out what value has been passed in SQL statement (from JDBC driver as prepared statement). > > I am using PostgreSQL 13 version. > > The following is the SQL statement I am running in PGAdmin > > The output I am getting is below, where in the SQL query is with $1. > > [cid:image001.png@01D74810.4207C100] > > Is there a way to compute what is being passed as value for the above SQL statement ? You should enable query logging, and pull the params out of the log. Note that v13 has log_parameter_max_length, which defaults to showing params in full. [pryzbyj@telsasoft2019 ~]$ PGOPTIONS='-c log_min_duration_statement=0 -c client_min_messages=debug' python3 -c "import pg; db=pg.DB('postgres'); q=db.query('SELECT \$1', 1)" DEBUG: loaded library "auto_explain" DEBUG: parse : SELECT $1 LOG: duration: 0.230 ms parse : SELECT $1 DEBUG: bind to LOG: duration: 0.141 ms bind : SELECT $1 DETAIL: parameters: $1 = '1' LOG: duration: 0.029 ms execute : SELECT $1 DETAIL: parameters: $1 = '1' -- Justin