Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uFYZi-005nU0-DL for pgsql-performance@arkaria.postgresql.org; Thu, 15 May 2025 13:24:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uFYZg-00EWXI-Ga for pgsql-performance@arkaria.postgresql.org; Thu, 15 May 2025 13:24:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uFYZg-00EWXA-6V for pgsql-performance@lists.postgresql.org; Thu, 15 May 2025 13:24:36 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uFYZd-001vPY-11 for pgsql-performance@lists.postgresql.org; Thu, 15 May 2025 13:24:35 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 54FDOUMZ1761549; Thu, 15 May 2025 09:24:30 -0400 From: Tom Lane To: Laurenz Albe cc: James Pang , pgsql-performance@lists.postgresql.org Subject: Re: a lot of session wait on lock relation In-reply-to: <54994813530a36c0280fd8779e65ad1ad73d910a.camel@cybertec.at> References: <54994813530a36c0280fd8779e65ad1ad73d910a.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Thu, 15 May 2025 14:08:05 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11464.1747315470.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 15 May 2025 09:24:30 -0400 Message-ID: <11465.1747315470@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laurenz Albe writes: > On Thu, 2025-05-15 at 16:27 +0800, James Pang wrote: >> why inserts into partition table cause "relation lock" ? > Something else does; use the pg_blocking_pids() function with the proces= s ID of > a blocked backend to find out who is holding the lock. More specifically: the inserts are only trying to get a shared lock. If they are blocked, it's because some other operation is already holding an exclusive lock on the table and is not letting go. Look for uncommitted DDL changes. More details about that at [1]. regards, tom lane [1] https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-= TABLES