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 1ewazu-0003e7-24 for pgsql-general@arkaria.postgresql.org; Thu, 15 Mar 2018 22:05:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewazs-00036w-LA for pgsql-general@arkaria.postgresql.org; Thu, 15 Mar 2018 22:05:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewazs-00036X-A8 for pgsql-general@lists.postgresql.org; Thu, 15 Mar 2018 22:05:16 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewazp-0000Rd-8E for pgsql-general@lists.postgresql.org; Thu, 15 Mar 2018 22:05:14 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 656605F79C; Thu, 15 Mar 2018 18:05:12 -0400 (EDT) Date: Thu, 15 Mar 2018 18:05:12 -0400 From: Stephen Frost To: Enrico Thierbach Cc: Melvin Davidson , "pgsql-generallists.postgresql.org" Subject: Re: SELECT .. FOR UPDATE: find out who locked a row Message-ID: <20180315220512.GV2416@tamriel.snowman.net> References: <20180315204851.GU2416@tamriel.snowman.net> <206B6740-DCC5-4491-A87D-EEF5CBF8EA6B@open-lab.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XVFtFv3QWhmcqUfC" Content-Disposition: inline In-Reply-To: <206B6740-DCC5-4491-A87D-EEF5CBF8EA6B@open-lab.org> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --XVFtFv3QWhmcqUfC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Greetnigs, * Enrico Thierbach (eno@open-lab.org) wrote: > I guess with your query I can figure out which connection holds a lock, but > it seems I cannot correlate those locks to the rows which actually are > locked, since `pg_locks` seems not to reference this in any way. What I gave you would work, or you could use the pgrowlocks extension: https://www.postgresql.org/docs/current/static/pgrowlocks.html Using pgrowlocks will be slow if you have a lot of records in the table though, hence the other approach I mentioned since it sounds like you know the ID that you're interested in. Thanks! Stephen --XVFtFv3QWhmcqUfC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaqu4YAAoJEO1sijiDR2RVicsP/j68WoWWTQgubRuORZcozqaI ePdmWcKgEdFL33DPvTfeYo73Wf7SngKMZGu/wQOOPg0wTIqmh7skxtRFd3f0oZRM 7vJ6v2etXDCp/4/u469XEcIX+6aeqqpW9XINjmkkczGzo/LV3SKVZlLP4h+YF6rt EgjcSKYQNc/oad4jErz/EmkHBaAWXtyTyLT7SMKryw+r3zQy7nUs+xtUPrhLZxJD dt/T1sqkFK6VQLY6EHKnwwKnoTZE+sq9XjTTu3LBf8DrNoHLTBRG0oHjP0wJDz0N O3PU50sh4UWRzQISSeBT3/cDDbcaa96UbJmLkGGwHTVz+1I1AahIqEumQdPG+VrU vQDrF1G4vWUp1BcKCMWNDuzg+1mg4umc9H6r6meyVbf/ThZ/z1DAzHTjobjFymXF b1xJoGoPxGO/Sf8ZIBwsaKFuFp/CWzsAjMMX3wfqpuicopNS/ztF4sDLNiS4+Ye+ /g5a+g23NoJ0b21WwA/T9olX2wvehwi7/lE4S019E4J4ac0isX3gmaqXHbPsutQr Wsyvh4EVXG0SPnVJVnQ46WmcUsiE8UXDtK7EFhfo9TIJbJgnAk75t3uqwN8QiJB6 870lvax+KVRLaJlSsSLab5iGqjdsaLsZOt+UzAkPhXpL5wFL18nmP1E/WmFecXCj Yk0kSAG4MYsM0eiumi27 =40Lm -----END PGP SIGNATURE----- --XVFtFv3QWhmcqUfC--