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 1rBJUZ-00AMjY-WD for pgsql-admin@arkaria.postgresql.org; Thu, 07 Dec 2023 18:53:00 +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 1rBJUY-001mBi-Io for pgsql-admin@arkaria.postgresql.org; Thu, 07 Dec 2023 18:52:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBJUY-001mBY-7v for pgsql-admin@lists.postgresql.org; Thu, 07 Dec 2023 18:52:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBJUU-00AbbY-S6 for pgsql-admin@lists.postgresql.org; Thu, 07 Dec 2023 18:52:57 +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 3B7Iqnr81300349; Thu, 7 Dec 2023 13:52:49 -0500 From: Tom Lane To: Holger Jakobs cc: pgsql-admin@lists.postgresql.org, rajeshkumar.dba09@gmail.com Subject: Re: Pg_dump In-reply-to: <404a126a-6229-7d83-9b86-70304a5693bc@jakobs.com> References: <404a126a-6229-7d83-9b86-70304a5693bc@jakobs.com> Comments: In-reply-to Holger Jakobs message dated "Thu, 07 Dec 2023 19:13:40 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1300347.1701975169.1@sss.pgh.pa.us> Date: Thu, 07 Dec 2023 13:52:49 -0500 Message-ID: <1300348.1701975169@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Holger Jakobs writes: > Am 07.12.23 um 19:11 schrieb Rajesh Kumar: >> Will pg_dump cause blocking queries? If so how to take dump without >> blocking? > Readers don't block writers, writers don't block readers in PostgreSQL. > pg_dump is a reader. To enlarge on that a bit: pg_dump takes AccessShareLock on every table it intends to dump. This does not conflict with ordinary DML updates. It *will* conflict with anything that wants AccessExclusiveLock, which typically is schema-altering DDL. See https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES So the answer to your question is "don't try to alter the database schema while pg_dump is running". You can alter database content freely, though. regards, tom lane