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 1u5fX4-004DCD-8A for pgsql-admin@arkaria.postgresql.org; Fri, 18 Apr 2025 06:49:02 +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 1u5fX2-0085OT-2A for pgsql-admin@arkaria.postgresql.org; Fri, 18 Apr 2025 06:49:00 +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 1u5fX1-0085JO-Ko for pgsql-admin@lists.postgresql.org; Fri, 18 Apr 2025 06:49:00 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u5fX0-000fOh-0L for pgsql-admin@postgresql.org; Fri, 18 Apr 2025 06:48:59 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-43cf034d4abso8036445e9.3 for ; Thu, 17 Apr 2025 23:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1744958937; x=1745563737; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=J/mEtoPx03qN/aw8vMg72DK83PyXEojIUMVeyLzYyls=; b=TFyJQyLV/r27SrZlyQPizLcW+t3zugtoHoOyYSxK85uU1TiUrSjDp5CcmosiD09PYj N3Xjv2wLyq9xKpiblEZ7fwqLwjgwPgFjYMJNWDrcbMFA+0KxwShmknw9wOW8ehzg3mLu 4vRbiBsUU7BzuEdJ3OWsH+THX41wkXjW/i4YXki/8uuNObPtSUY02RcgpQQHXyuH0vYy W+Y0KSftWgXZkxnUq+tpttTyq4BkPMoXHwuRQg7iYAXpyA59o5I7T/T/l8vpfbOHfdsL RLw8erxGmVEcAmQy1YM3P8pjmyIE3CuR1zu4uREFImb1/JlaCKTlhX7ZQiNEQYPCD3/x 0+kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744958937; x=1745563737; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=J/mEtoPx03qN/aw8vMg72DK83PyXEojIUMVeyLzYyls=; b=Li7bNcW0cu1iGUivdnNxzj3LJkUuhHSKkubNznrbe/RhI7k7E+lK8znDrd6RxxcabM Nm2XL7kR1kqUFwH7owdTCkKiPV+178kZB2iQ3BUtI01KSyRN4A4go+Evw5czzwzQ5CHE oFZdR7iPYU7twWd9ehD8SQyMKR8rObvB+dYBv7ZvkLoKIfiSOazM6m3wydXjBQoek/M1 l4w2KlCfE73Cv+09Tfx9+JNQMxiHDXedaLwzItr2zmH8fAUvaV1RlolOvMX/tbYRbqhS LEUhPO8OfEKrHwP0g/JphsKGyiYMQ8lTDL3sy5PgsBVzLskVhVB8giKNQYLinHVR5Mpb wYpA== X-Forwarded-Encrypted: i=1; AJvYcCWg76velRZLZDCfIdK9gllvX2c+xlEDGJq+Qb7WnxumMZbeYNgn07OZiiG6ivUZc468udJHXbbHoU7Vew==@postgresql.org X-Gm-Message-State: AOJu0YxCzZsh+WLb+cIn0tyyKp8TrscoHxCQC15N4PXYeJZ5jJsOWcBn P2KaFD+fzOGP+mveJ1+gwnvklSo5jJ0yS4RVfjRE5t5ImtTodbotXM54VKl9M0SAMGuwgZBwF+I W X-Gm-Gg: ASbGncs+7c9m9GJ12cpiK8LyXjfcho9veM3gaUAKpcuWdMGLSsj1reOLKz9ogq2VkOP tHEqfS/2sel3GqNGBV4m/HyHs/1qs1y1ia3sXyYtOq5T/Jk9SSH/l9VqugvLRzXKf0vEYn6xb3S MEvgtN+wcZtATBNHQuNVysLgNAbWfFwwH4qZdLczws083Z8OTcClgggw+hGCCukhWaMTqxEuhk/ Y9U8yNKnBZ3ZQ+tMa2fTa3FeZY7IhxGgQfwaKq/b14DWUABoheOmGqCURRZtH5EIjIfQ46cERDw 6blzyEvZP6zzMZmnIFdi+r7R5zjh1c4LMxMmPwuYpwZcLMJ4ES8KH6FeITr2 X-Google-Smtp-Source: AGHT+IHGvLTx9teKG/pte/nkX6CLLNzIzdSQW7vbBnGQxaKAThMJHtT8XsKhkowxg4wizKKvVbILvw== X-Received: by 2002:a05:600c:3583:b0:43c:ed61:2c26 with SMTP id 5b1f17b1804b1-4406abb2407mr11534365e9.17.1744958936734; Thu, 17 Apr 2025 23:48:56 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:5373:9d9a:af04:78c5:75aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39efa4a4856sm1777322f8f.81.2025.04.17.23.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Apr 2025 23:48:56 -0700 (PDT) Message-ID: Subject: Re: Replication lag From: Laurenz Albe To: "Gaspare Boscarino, P.Eng." , Wasim Devale Cc: Pgsql-admin , pgsql-admin Date: Fri, 18 Apr 2025 08:48:55 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Thu, Apr 17, 2025 at 5:15=E2=80=AFAM Wasim Devale = wrote: > > Does wal_level =3D logical can resolve the issue of replication lag? > >=20 > > > We have a setup of primary and replica database. We are using the rep= lica as > > > read only purpose. But the queries are long running queries that take= s 30 minutes > > > to complete. > > >=20 > > > Do we have any settings in place that will not show replication lag a= nd the > > > queries also executes on replica database without competition on WAL = reply? > > >=20 > > > The settings: > > > Hot standby is off > > > And maximum streaming delay is set to -1 In short: no. A more detailed discussion: If I understand correctly, you are fighting with replication conflicts, and= you want no replay delay and no canceled queries. The only way you can have that is if you don't have replication conflicts, = and that is something you can guarantee. However, you can reduce the frequency= of replication conflicts: - Setting "hot_standby_feedback =3D on" will probably get rid of the majori= ty of replication conflicts, but the price is that long-running queries on the = standby can bloat the tables and indexes on the primary. - Setting "vacuum_truncate =3D off" (available from v18 on) will get rid of= another set of replication conflicts. Before v18, you'd have to disable VACUUM t= runcation on each table individually. You will probably still get some buffer pin replication conflicts, and comm= ands like TRUNCATE, ALTER TABLE or VACUUM (FULL) will always cause them. Changing "wal_level" has no impact on all that, except that if you set it t= o "minimal", you cannot have replication any more, which would get rid of rep= lication conflicts. Similarly, setting "hot_standby =3D off" on the standby would immediately g= et rid of all replication conflicts, because you could no longer connect to the stand= by and run queries there. Yours, Laurenz Albe