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 1qRw7E-003f4e-8j for pgsql-admin@arkaria.postgresql.org; Fri, 04 Aug 2023 14:49:20 +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 1qRw6E-008Gpg-4N for pgsql-admin@arkaria.postgresql.org; Fri, 04 Aug 2023 14:48:18 +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 1qRw6D-008GpY-PX for pgsql-admin@lists.postgresql.org; Fri, 04 Aug 2023 14:48:18 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qRw69-000Vze-S2 for pgsql-admin@lists.postgresql.org; Fri, 04 Aug 2023 14:48:16 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-267f8f36a3cso1203769a91.2 for ; Fri, 04 Aug 2023 07:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691160493; x=1691765293; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=g7RgQvc1a6VNwHW0FeUPpiTuQeuE7aayJwLHNmVBtjc=; b=RS4KEeut5SXUq70I8SGp/c+hAlrkjtJN40TLErtK8PGCb2fQeBOJhllsCii4Fer8pV QHqqHW2SrVXoYinqDnXDEDVV+TZTZdb6tdx0uNkxl5U8EFYafsVsjwifVaZ3UYweRhMy 6/8vPPvQWVqgYGKyKe/aF0pjqHU/x8+mrMtyF58UunKF+xo69d0ivuL4utJWz6aGnWQF x5snZ0EVgH2jgXUuNZbRnl3rFx0WfD2uk+6gKMxhT7QPDzJG93nFvTW9VVEXXVAkcI2c 4E51RZrRMMjq4z2fEz4bBGTwYcnv3AZXe5jANdBB8uYYJ1Su0z2Q6h/fpfWPE2CIZGv+ oPMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691160493; x=1691765293; 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=g7RgQvc1a6VNwHW0FeUPpiTuQeuE7aayJwLHNmVBtjc=; b=ZvoAAlXGDLN4RUyUA2nScmjnJ5xqiqPDSV+NA8P20CpR5L5dvitC8unuuzgSKQb2C4 AxiXmgrRJQr2NFHtyTxSjgVEuB1Pp/qQPYllRThu/B6wvrSTg3vi/1PgWknMekd7fT2p IMudihOadCbo24bbNHFU9xs/jcIXKWB2IwE1RUkrb7eqcDkUIhXpkUVmb86pIdho58ND nsY/OtRdArsdbV3xiPEl4f8Bg4gsUxAQ8jMTq5BcnXZKxSNUJmE0+ofnj06pF4N96yO8 /hqqmP+snvK6JnrQE2AFDQiKA1NZoZ/FfhsSlYE+k33eqxsl5HhUtrhs4O2SCekiqAtb nGew== X-Gm-Message-State: AOJu0Yxrcr7WPnAPtw6t0OH7SXeoFhdO8ty8Tb+pyt/n0oFCpF5pZH3r wIWmfHKe7NfogR0MAtJUam8Dlhacdg5n102T5A== X-Google-Smtp-Source: AGHT+IFv3BHfzdyenVchTfQWX7HgNxCm34GSgS7xRzp8MKPljB9gB2SHen+/+4hyDX34Q4WVvTaSvho2oRSFvTAHvqY= X-Received: by 2002:a17:90b:1192:b0:263:4e41:bdb4 with SMTP id gk18-20020a17090b119200b002634e41bdb4mr1555646pjb.33.1691160492786; Fri, 04 Aug 2023 07:48:12 -0700 (PDT) MIME-Version: 1.0 References: <615ccd4a1de716c229cf125260896051b1989608.camel@cybertec.at> In-Reply-To: <615ccd4a1de716c229cf125260896051b1989608.camel@cybertec.at> From: Jeff Janes Date: Fri, 4 Aug 2023 10:48:00 -0400 Message-ID: Subject: Re: analyze foreign tables To: Laurenz Albe Cc: richard coleman , Pgsql-admin Content-Type: multipart/alternative; boundary="0000000000006e4840060219fcd7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006e4840060219fcd7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Aug 3, 2023 at 8:37=E2=80=AFAM Laurenz Albe wrote: > On Tue, 2023-08-01 at 09:47 -0400, richard coleman wrote: > > In PostgreSQL foreign tables are not automatically analyzed and analyze > must be > > specifically called on each table. In the case of sharing tables > between PostgreSQL > > clusters, there is the use_remote_estimate foreign server option. > > > > In some of our multi terabyte databases, manually running analyze on al= l > of the > > foreign tables can take more than a day. This is per database > containing the > > foreign schema. Since we have certain large schema that we have > centrally located > > and share to all of our other database clusters, this really adds up. > > I just saw that PostgreSQL v16 uses remote sampling for ANALYZE on foreig= n > tables. > This is governed by the option "analyze_sampling" on the foreign table or > the foreign > server, and the default value "auto" should be just what you need. > > In addition to this new feature, analyzing foreign tables can also be highly dependent on an old feature, fetch_size. The default fetch_size is really quite small and might be a bottleneck for ANALYZE. Cheers, Jeff --0000000000006e4840060219fcd7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Aug 3, 2023 at 8:37=E2=80=AFAM La= urenz Albe <laurenz.albe@cyb= ertec.at> wrote:
On Tue, 2023-08-01 at 09:47 -0400, richa= rd coleman wrote:
> In PostgreSQL foreign tables are not automatically analyzed and analyz= e must be
> specifically called on each table.=C2=A0 In the case of sharing tables= between PostgreSQL
> clusters, there is the=C2=A0use_remote_estimate foreign server option.=
>
> In some of our multi terabyte databases, manually running analyze on a= ll of the
> foreign tables can take more than a day.=C2=A0 This is per database co= ntaining the
> foreign schema.=C2=A0 Since we have certain large schema that we have = centrally located
> and share to all of our other database clusters, this really adds up.<= br>
I just saw that PostgreSQL v16 uses remote sampling for ANALYZE on foreign = tables.
This is governed by the option "analyze_sampling" on the foreign = table or the foreign
server, and the default value "auto" should be just what you need= .


In addition to this=C2=A0new feature, = analyzing foreign tables can also be highly dependent on an old feature, fe= tch_size.=C2=A0 The default fetch_size is really quite small and might be a= bottleneck for ANALYZE.

Cheers,

Jeff
--0000000000006e4840060219fcd7--