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 1rQQMX-0019FH-0K for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jan 2024 11:15:09 +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 1rQQMV-001xMW-Ph for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jan 2024 11:15:07 +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 1rQQMV-001xMO-EZ for pgsql-hackers@lists.postgresql.org; Thu, 18 Jan 2024 11:15:07 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rQQMO-0028n2-9p for pgsql-hackers@lists.postgresql.org; Thu, 18 Jan 2024 11:15:06 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2cd2f472665so128755041fa.2 for ; Thu, 18 Jan 2024 03:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705576498; x=1706181298; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DHiWxIO1C7njo9Qt+OlKu3xfg50+4qHarhw+9jeVsJo=; b=HZIDcvZS9nCA2BCnnF+vKLEqgilCvFO4B2maHqwNBFBgyljANsPmNLWoERepRD0OjE m4TAVIWpT/nzZ22fSM3hdVcZ4PRDVUlfl5ExbJQs4pZxoS/VYBbrvq1FreqpRtsji7O7 rjQyANXXz9w1mdyE7tMQmwsNpqYb7l2cfhAywOOsIbBS/XWKB9gkjZYBuyDnnPcRKevr KThi9LKAcP7mgLkOW5dKCd6HUJv2bRdspFW9YPH5tbIo1QhwL3AAfvvpVsBSnq0ZgurY ylqFxrhoIyMMLYH8gQ8iCsRNxTEnyIJ/7TlRmh7AUrkAtQiEJhq3GoSH9fi4TX9VsJ8W oW9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705576498; x=1706181298; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DHiWxIO1C7njo9Qt+OlKu3xfg50+4qHarhw+9jeVsJo=; b=kLBea39WBrL131HlDV2yQDXtByWHMII8eQjwQgiDQgliugENSish20LryR+NlBKLrS i5fWzCAfOsD3GFeVzwRQHgA5F+sZSDuGaolB0p2/1/eI+kE9t97aLNb0iHvYf16ZnwRu NfIWmSdUDJ424+HPNlb3YDWwW4p4VZL9ft0/E/bsPlOUf/ua2fSxRCni4+JzgP6PXRNI Db5fFUcut/alxdh7xnLv/jM+Km/GeCqdr24NyPYWjCR0BkKUXggPzbd/VfF9yJ1yp1bb j8fntMu8bmRqTalUPy/lpy4T2kzEbecbc4J1h90TclpOn2yISJwOwpoojkkcal1hg4iE mwvg== X-Gm-Message-State: AOJu0Yz4jijKJIUTBcGMh7Tgk9DZNBEiayR0nx+WNcF0WnpShJzKzvZZ waSy/hmeFKze7VBpYSvl9mepv9MZ/B1qFrLlyWx+c6GYDZCB4BuOH321dAoSeNyxQh+eBLpZoVl rCEPlzgOGybHy0yZmZ758iB9JvOQriq/QOTA= X-Google-Smtp-Source: AGHT+IFNivYYCRL5uCQlWi0ETuYHbhJZV4ig9W4sMAcABFM0BbVwQm5mu3Eb+mNGBl/ULugE0y8QZjGMIiWXWnGCHU4= X-Received: by 2002:a2e:a54f:0:b0:2cc:daca:2e81 with SMTP id e15-20020a2ea54f000000b002ccdaca2e81mr561193ljn.15.1705576498306; Thu, 18 Jan 2024 03:14:58 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bharath Rupireddy Date: Thu, 18 Jan 2024 16:44:00 +0530 Message-ID: Subject: Re: Reduce useless changes before reassembly during logical replication To: Amit Kapila Cc: li jie , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 18, 2024 at 2:47=E2=80=AFPM Amit Kapila wrote: > > On Thu, Jan 18, 2024 at 12:12=E2=80=AFPM Bharath Rupireddy > wrote: > > > > On Wed, Jan 17, 2024 at 11:45=E2=80=AFAM li jie wro= te: > > > > > > Hi hackers, > > > > > > During logical replication, if there is a large write transaction, so= me > > > spill files will be written to disk, depending on the setting of > > > logical_decoding_work_mem. > > > > > > This behavior can effectively avoid OOM, but if the transaction > > > generates a lot of change before commit, a large number of files may > > > fill the disk. For example, you can update a TB-level table. > > > > > > However, I found an inelegant phenomenon. If the modified large table= is not > > > published, its changes will also be written with a large number of sp= ill files. > > > Look at an example below: > > > > Thanks. I agree that decoding and queuing the changes of unpublished > > tables' data into reorder buffer is an unnecessary task for walsender. > > It takes processing efforts (CPU overhead), consumes disk space and > > uses memory configured via logical_decoding_work_mem for a replication > > connection inefficiently. > > > > This is all true but note that in successful cases (where the table is > published) all the work done by FilterByTable(accessing caches, > transaction-related stuff) can add noticeable overhead as anyway we do > that later in pgoutput_change(). Right. Overhead for published tables need to be studied. A possible way is to mark the checks performed in FilterByTable/filter_by_table_cb and skip the same checks in pgoutput_change. I'm not sure if this works without any issues though. --=20 Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com