Re: Initial COPY of Logical Replication is too slow

From: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Initial COPY of Logical Replication is too slow
Date: 2026-01-19 17:44:18
Message-ID: CAB-JLwZpp=7c9_r0beWWJxRh2BS_2Vvth8UDv7H57DBeaqggVg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sex., 19 de dez. de 2025 às 22:59, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
escreveu:

> Yeah, if we pass a publication that a lot of tables belong to to
> pg_get_publication_tables(), it could take a long time to return as it
> needs to construct many entries.

Well, I don't know how to help but I'm sure it's working badly.
Today I added some fields on my server, then seeing logs I could see how
slow this process is.

duration: 2213.872 ms statement: SELECT DISTINCT (CASE WHEN
(array_length(gpt.attrs, 1) = c.relnatts) THEN NULL ELSE gpt.attrs END)
FROM pg_publication p, LATERAL pg_get_publication_tables(p.pubname) gpt,
pg_class c WHERE gpt.relid = 274376788 AND c.oid = gpt.relid AND
p.pubname IN ( 'mypub' )

2 seconds to get the list of fields of a table is really too slow.
How can we solve this ?

regards
Marcos

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2026-01-19 18:02:27 Re: Enhancing Memory Context Statistics Reporting
Previous Message Kirill Reshke 2026-01-19 17:43:44 Re: SQL:2011 Application Time Update & Delete