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 1qRZAx-002CRN-1f for pgsql-admin@arkaria.postgresql.org; Thu, 03 Aug 2023 14:19:39 +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 1qRZAu-00DyV7-DT for pgsql-admin@arkaria.postgresql.org; Thu, 03 Aug 2023 14:19:36 +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 1qRZAu-00DyUz-2s for pgsql-admin@lists.postgresql.org; Thu, 03 Aug 2023 14:19:36 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qRZAr-000Lxq-Cm for pgsql-admin@lists.postgresql.org; Thu, 03 Aug 2023 14:19:35 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-55b1238cab4so516844a12.2 for ; Thu, 03 Aug 2023 07:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691072371; x=1691677171; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8/E9Mu+npRo2Ck+xJcOFxuqE4QtUQs97P9PVzH/+86c=; b=egyNShH1yY0GCZJQt7FKfTokTv45/MhQeLOxeaVPMMxzCToKQ3DvtfCRQ0JZIMrviL YL/qx8L+fmYmJq1x1D4DN9m4iIWGVTQyLEDw5EuC0OiEzWjKyt5/LMZCIKRsm8Ul6d7D C0h3xvO9UFQs8gt5995Cxq5UNLGAepba08Z185twvQSUEks4fxbhUMQS1WlWNLVCWagf XTg0WMy5t5iNPWrkdbC4LyPYPnjQevvQurmbG9xjIU/SwxzsrXADgkjp8IEb5RuXqVhi 05NmHiPgtcizGXLZQw65TF5N5nvvyqdCVOW9XMn+Ha/VCQcA7WMITwaerDKp9qLmGhFg OfhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691072371; x=1691677171; h=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=8/E9Mu+npRo2Ck+xJcOFxuqE4QtUQs97P9PVzH/+86c=; b=TT0aNHjVwmlU1vIgLoTKb7377uR2pb0Bx8wuDthBlsXtg92KJZJiBl7jm3fLpooSXo geW8I0Ylg6IzuzbNSdZuQk+hYTx6H4YTjmyvkLHV9Adw/nAOfE/R6BPcLtA3KE7pRxgu Pla2l1JrIB3CoNWLOU2r+2rWChBgP7xRmdkmN37WyglRm4+IzkDnbvu/oND1sVjgOITf krTx98cEd96sDhiKhJWT3swTLFg0q5gYv54Pxkf2Wea1Asi9keEFIzH4O2gH66tPDm5r 2iKkduhmc9s1RuCP55o6HBx/GN3VfD6g+MYoP8dOtgD5aNB4QiTM4Kn9KOYEHQrT8Kks KXDw== X-Gm-Message-State: ABy/qLYU7yLP7iD9aaVEwJTYvig0YiJzNTfZedGlLCX3tiTxEOYlRB5r kWqgtXfQkteX1u1xzlaJMUOlFstzjYrO6ewGzA== X-Google-Smtp-Source: APBJJlEiEb31isPWK5vVcD19evgYKl7y1207nBpUko+GAgvUhLXPC0h33Yle/4E/XME/mpOXQzVKtFJVtMy3xuR6MgA= X-Received: by 2002:a17:90b:4f81:b0:268:17aa:8b78 with SMTP id qe1-20020a17090b4f8100b0026817aa8b78mr16198052pjb.20.1691072370743; Thu, 03 Aug 2023 07:19:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jeff Janes Date: Thu, 3 Aug 2023 10:19:19 -0400 Message-ID: Subject: Re: analyze foreign tables To: richard coleman Cc: Pgsql-admin Content-Type: multipart/alternative; boundary="000000000000f29cb806020577cc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f29cb806020577cc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Aug 1, 2023 at 9:47=E2=80=AFAM richard coleman wrote: > > use_remote_estimate isn't really a solution as it adds way too much > overhead and processing time to every query run. > Maybe this is the thing which should be addressed. Can you quantify what you see here? How much overhead is being added for each query? Is this principally processing time, or network latency? Since these tables are being continuously analyzed in the database that > hosts the data, is there some way that they statistics could be easily > passed through the foreign server mechanism to the remote database that's > calling the query? > Since FDW can cross version boundaries, it is hard to see how this would work. Maybe something could be done for the special case of where the versions match. I think collations/encoding would be a problem, though. > What I am hoping for is either: > > 2. add the ability to automatically run analyze on foreign tables just as > they are currently run on local tables. > That wouldn't work because communication is always initiated on the wrong side. But it should be fairly easy to script something outside of the database which would connect to both, and poll the "foreign" pg_stat_all_tables.last_autovacuum and initiate a local ANALYZE for each table which was recently autoanalyzed on the foreign side. Cheers, Jeff --000000000000f29cb806020577cc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Aug 1, 2023 at 9:47=E2=80=AFAM ri= chard coleman <rcoleman.a= scentgl@gmail.com> wrote:

use_remote_estimate isn't really a solution as it adds way too mu= ch overhead and processing time to every query run.

Maybe this is the thing which should be addressed.= =C2=A0 Can you=C2=A0quantify what you see here?=C2=A0 How much overhead is = being added for each query?=C2=A0 Is this principally processing time, or n= etwork latency?


Since these tables are bein= g continuously analyzed in the database that hosts the data, is there some = way that they statistics could be easily passed through the foreign server = mechanism to the remote database that's calling the query?
<= /blockquote>

Since FDW can cross version boundaries, it = is hard to see how this would work.=C2=A0 Maybe something could be done for= the special case of where the versions match. I think collations/encoding = would be a problem, though.


What I am hopin= g for is either:

2. add the ability t= o automatically run analyze on foreign tables just as they are currently ru= n on local tables.

That wouldn&= #39;t work because communication is always initiated on the wrong side.=C2= =A0 But it should be fairly easy to script something outside of the databas= e which would connect to both, and poll the "foreign" pg_stat_all= _tables.last_autovacuum and initiate a local ANALYZE for each table which w= as recently autoanalyzed on the foreign side.=C2=A0

Cheers,

Jeff
--000000000000f29cb806020577cc--