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 1sIk0y-0004EK-QJ for pgsql-general@arkaria.postgresql.org; Sun, 16 Jun 2024 07:09:24 +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 1sIk0v-0047n9-Bx for pgsql-general@arkaria.postgresql.org; Sun, 16 Jun 2024 07:09:22 +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 1sIk0u-0047n1-Uo for pgsql-general@lists.postgresql.org; Sun, 16 Jun 2024 07:09:21 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sIk0t-001vjX-OC for pgsql-general@lists.postgresql.org; Sun, 16 Jun 2024 07:09:21 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-24542b8607fso1832690fac.1 for ; Sun, 16 Jun 2024 00:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718521758; x=1719126558; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cobqqpH/gFMOEK4J6hWFf/MbXDBWhwrAcct991VSZXI=; b=Bn79i/mZ1uRNG8HegkeJvw1YrS0h/uZkSAO2p9lxfODVhmUjADkhNcEwPMycKPn5N2 0GgI9aunYA4WyiV7KwkH0LDNe+QeOY4nVvrrDm41tlr3As/rkB/NyrabKeasCYs1EwLd BDvggTOrq+GhjHnJxiOqUKKVkUjbATctkvlgCY2xCeQKdUXv64GmbnhEDq56HaJaFXQb 87XH6Rc2oegri5csQhbuuFz0mVgU68gEUfuuZ69m2Aj+MQd6Sy4ONuI5ngSBMM172XKA Xcrd1JdfUV0QwCi1OonN+XqCnjVomQgwCbDrTtnsjpjLV02BtkYahSKdkytm8yq/YVp3 fv5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718521758; x=1719126558; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cobqqpH/gFMOEK4J6hWFf/MbXDBWhwrAcct991VSZXI=; b=KXjKuDsbcZ+TZzqLMq/ZxtXCeQRwVIEKjJUCY5onycxxV5DBlU8Sma53TGxXAQ5ZBH 7KJv7B61DFsj5FlRT4jc+dOaPDex5zQ1gaQFk+V0HfdyRBkiUBWYAr5yfVNP6sRrKJ7g yCYakO1nInT5Sto4SfcppqD81IMeG5WVLpw67V/QKy00CUTasDL/+IwARvvrfzvhr7l2 FzU0kPOMPtQCVjkwkk7QAuxo9QDc3M/+nBF6lTeaefsePUFLZvKAfAdRc1SzayqNABqJ x0XrmXljsvXO+D3xagVYU65Bng9SJbf5TOxJ1kRDzsUVI+w9IaiT4G6fNPc0jN6j4w3N VPeQ== X-Gm-Message-State: AOJu0YxwZh8iufHVvljgK0VQh2zI2pr6yqnUfrzGHvBqM2l2VjceRIQl 78wN2Vy9Rql/dP0RkglIjJxmQ4plbmStdemi9bAsX5JeOLjpTYuywNB1tzOknDINC3clOWEs/30 KSkTARf/9CVZkHjKR28WEnhL3dgM= X-Google-Smtp-Source: AGHT+IE49CnRuQgFZZa1zYO4MycDPPItNGumnMWdopBzIj7/cmrQg/VA3G9ndB4jZnQC0MvLvLV3Okk8YAmw/Vy2XWc= X-Received: by 2002:a05:6871:20a:b0:254:bb9e:7d75 with SMTP id 586e51a60fabf-258428eb259mr6893169fac.15.1718521757680; Sun, 16 Jun 2024 00:09:17 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:d89:0:b0:530:392d:d678 with HTTP; Sun, 16 Jun 2024 00:09:17 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Sun, 16 Jun 2024 00:09:17 -0700 Message-ID: Subject: Re: Is a VACUUM or ANALYZE necessary after logical replication? To: Koen De Groote Cc: PostgreSQL General Content-Type: multipart/alternative; boundary="000000000000e7cf2d061afc8631" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e7cf2d061afc8631 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Saturday, June 15, 2024, Koen De Groote wrote: > I've gone over all of https://www.postgresql.org/docs/current/logical- > replication.html and the only mentions of the word "index" I could find > was in relation to replica identity and examples of table definitions > showing primary key indexes. > > Nothing is said about indexes. Maybe for good reason, maybe they are full= y > functionality immediately after replication? > > So the main question: Once a table is fully replicated, do I need to > vacuum(analyze) that table, or are the indexes on that table already > functional? > The whole point of =E2=80=9Clogical=E2=80=9D replication is that the inserts/updates/deletes are reapplied on the secondary against the table and the whatever triggers, indexes, or whatnot exist on that table in the secondary behave just as if you connected to the server directly and issued the corresponding SQL against it. As far as the replication system is concerned none of those things on the primary matter nor does it have to care about them on the secondary. David J. --000000000000e7cf2d061afc8631 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Saturday, June 15, 2024, Koen De Groote <kdg.dev@gmail.com> wrote:
I've gone over all of https:= //www.postgresql.org/docs/current/logical-replication.html an= d the only mentions of the word "index" I could find was in relat= ion to replica identity and examples of table definitions showing primary k= ey indexes.

Nothing is said about indexes. Maybe f= or good reason, maybe they are fully functionality immediately after replic= ation?

So the main question: Once a table is fully= replicated, do I need to vacuum(analyze) that table, or are the indexes on= that table already functional?

The whole point of =E2=80=9Clogical=E2=80=9D replication is that the inser= ts/updates/deletes are reapplied on the secondary against the table and the= whatever triggers, indexes, or whatnot exist on that table in the secondar= y behave just as if you connected to the server directly and issued the cor= responding SQL against it. As far as the replication system is concerned no= ne of those things on the primary matter nor does it have to care about the= m on the secondary.

David J.

--000000000000e7cf2d061afc8631--