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 1rnfjT-00ESMf-Sp for pgsql-general@arkaria.postgresql.org; Fri, 22 Mar 2024 14:18:56 +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 1rnfjS-0048Zj-8m for pgsql-general@arkaria.postgresql.org; Fri, 22 Mar 2024 14:18:54 +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 1rnfjR-0048Za-Ug for pgsql-general@lists.postgresql.org; Fri, 22 Mar 2024 14:18:54 +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.94.2) (envelope-from ) id 1rnfjO-005rSe-RF for pgsql-general@lists.postgresql.org; Fri, 22 Mar 2024 14:18:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42MEIo9t899844; Fri, 22 Mar 2024 10:18:50 -0400 From: Tom Lane To: arun chirappurath cc: pgsql-general@lists.postgresql.org Subject: Re: pg_locks-exclusivelock for select queries In-reply-to: References: Comments: In-reply-to arun chirappurath message dated "Fri, 22 Mar 2024 12:43:40 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <899842.1711117130.1@sss.pgh.pa.us> Date: Fri, 22 Mar 2024 10:18:50 -0400 Message-ID: <899843.1711117130@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk arun chirappurath writes: > I am running below query on a database. why is it creating a exclusive lock > on a virtualxid? I am running some SELECT queries and its creating an > ExclusiveLock in virtualxid? is this normal? Yes. That lock has nothing to do with any table, only with the transaction's own existence. It can't conflict when acquired, because the virtual XID is unique (at least across existing sessions). It exists so that other sessions can wait for this one if needful, by trying to take share lock on the virtualxid. regards, tom lane