Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzSDw-00019R-FZ for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 20:24:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzSDv-0005cX-3I for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 20:24:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzSDu-0005cP-RB for pgsql-general@lists.postgresql.org; Thu, 28 Feb 2019 20:24:06 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzSDd-00050z-LB for pgsql-general@postgresql.org; Thu, 28 Feb 2019 20:24:06 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id BB128124DE366 for ; Thu, 28 Feb 2019 13:23:46 -0700 (MST) Date: Thu, 28 Feb 2019 13:23:46 -0700 (MST) From: PegoraroF10 To: pgsql-general@postgresql.org Message-ID: <1551385426763-0.post@n3.nabble.com> Subject: =?UTF-8?Q?Refresh_Publication_takes_hours_and_doesn=C2=B4t_finish?= MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_131672_1202958803.1551385426763" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_131672_1202958803.1551385426763 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable *We use logical replication from a PG version 10.6 to a 11.2. Both are Ubun= tu 16.04.We have a hundred schemas with more or less a hundred tables, so number of tables is about 10.000. All replication is ok but when we try to do a REFRESH SUBSCRIPTION because we added a new schema, it takes hours and doesn=C2=B4t finish. Then, if I go to our master server and do a select * f= rom pg_publication_tables it doesn=C2=B4t respond too. Then, analysing the sour= ce of view pg_publication_tables ...* create view pg_publication_tables as SELECT p.pubname, n.nspname AS schemaname, c.relname AS tablename FROM pg_publication p, (pg_class c JOIN pg_namespace n ON ((n.oid =3D c.relnamespace))) WHERE (c.oid IN (SELECT pg_get_publication_tables.relid FROM pg_get_publication_tables((p.pubname) :: text) pg_get_publication_tables (relid))); If we run both statements of that view separately=20 SELECT string_agg(pg_get_publication_tables.relid::text,',') FROM pg_get_publication_tables(('MyPublication')::text) pg_get_publication_table= s (relid); *put all those oids retrieved on that IN of the view* select * from pg_Class c JOIN pg_namespace n ON n.oid =3D c.relnamespace WH= ERE c.oid IN ( *OIDs List* ); *Then it responds immediatelly* So, the question is .. can we change this view to select faster ? Just rewriting that view to a better select will solve ?Is this view used by REFRESH SUBSCRIPTION ? We think yes because if we run refresh subscription or select from view it doesn=C2=B4t respond, so ... -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.ht= ml ------=_Part_131672_1202958803.1551385426763 Content-Type: text/html; charset=UTF8 Content-Transfer-Encoding: quoted-printable We use logical replication from a PG version 10.6 to a 11.2. Both are Ub= untu 16.04. We have a hundred schemas with more or less a hundred tables, so number of = tables is about 10.000. All replication is ok but when we try to do a REFRE= SH SUBSCRIPTION because we added a new schema, it takes hours and doesn=C2= =B4t finish. Then, if I go to our master server and do a select * from pg_p= ublication_tables it doesn=C2=B4t respond too. Then, analysing the source o= f view pg_publication_tables ...

create view pg_publication_tables as
  SELECT p.pubname, n.nspname AS schemaname, c.relname AS tablename FROM pg=
_publication p,
  (pg_class c JOIN pg_namespace n ON ((n.oid =3D c.relnamespace))) WHERE (c=
.oid IN (SELECT pg_get_publication_tables.relid FROM pg_get_publication_tab=
les((p.pubname) :: text) pg_get_publication_tables (relid)));
If we run both statements of that view separately=20
SELECT string_agg(pg_get_publication_tables.relid::text,',') FROM pg_get_pu=
blication_tables(('MyPublication')::text) pg_get_publication_tables (relid)=
;
put all those oids retrieved on that IN of the view
select * from pg_Class c JOIN pg_namespace n ON n.oid =3D c.relnamespace=20
WHERE c.oid IN (
OIDs List
);
Then it responds immediatelly

So, the question is .. can we change this view to select faster ? Just rewr= iting that view to a better select will solve ? Is this view used by REFRESH SUBSCRIPTION ? We think yes because if we run = refresh subscription or select from view it doesn=C2=B4t respond, so ... =09 =09 =09


Sent from the PostgreSQL - general mailing list archive at Nabble.c= om.
------=_Part_131672_1202958803.1551385426763--