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.96) (envelope-from ) id 1wg0M2-005qge-36 for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jul 2026 13:24:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wg0M1-00AH45-2f for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jul 2026 13:24:21 +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.96) (envelope-from ) id 1wg0M1-00AH3v-0v for pgsql-hackers@lists.postgresql.org; Sat, 04 Jul 2026 13:24:21 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wg0Ly-00000001SnD-41bW for pgsql-hackers@lists.postgresql.org; Sat, 04 Jul 2026 13:24:20 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-845c92bc464so1013749b3a.2 for ; Sat, 04 Jul 2026 06:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783171458; x=1783776258; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AdVv6OknW2XQ1LoC4Xh7jmZy+ecg/4DVyzizL2cvPUw=; b=hvlzRLpN6R2AyLzlf0Ob59xwJThBDFQLP5zoFCxrjBkOswF/Dee6NzucXtAsL97yzs +dnbrsPnXshttg6+noe1dpXyPiAqDOoyfoOkTmQcIsUGhoCwaImFy3ESiZvbVphnjBhD 2sbmXoEeQjZ82yPTdl2v4kl7xE1XiX3Oq9YwesEhHLbroEUuJOikXesEWfvaWApot4nG hfcWO/srmuSowKzm1sUQQUdvcAbmWlkhwcPseqIplmLfiR0/wqEw771ao7SE43zFXx0B kgmN5GaBKZRPMSeXxGNwy7pl9sGsQn84AMPFWvLv86EPN9okIM7RlGzXSXmyl4n1Ahra s+jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783171458; x=1783776258; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AdVv6OknW2XQ1LoC4Xh7jmZy+ecg/4DVyzizL2cvPUw=; b=tDwRK5lnlhp22WWq3WxWJTt0aQSgN3sX6ArxH803zrmkRD058iZt0wErnBmVzUBIKf NAHeLkYyiC1995//celBAsojZR+tZZPRjdTv8IgpeXBYZkVmW6TTajauTa23aYtNmgcm 3ALFUVJpdIYKPlGOSFw/9+LPV3qLa+feam7SC/D9k7XkPFaidCEdf3ShlLxT/4ubiPUZ NAMWUTLXTq/OtJJg0BgZ6/lbkJS0o3DMUITk/CoqkQNGUa0792v0K40Zg21q2Wny8dLO 4oz6kxcl2y+Uc1A33ib9dsy7AbTdmtNcKAgRfc27ReKcY7fHxBhSNoRFqV9n8UNeqEQu vi7Q== X-Gm-Message-State: AOJu0Yxath8pGXAwA3R1VyKfqWQK+hpKSL4+loBi17JOVPGCMdwTQYtl IR86a8QkRiHDNy/lmOaNKEDcWWXOYZk9pty66wNNonyPWqIvEvw6bteIvNHINkIs X-Gm-Gg: AfdE7cla8F/t9pZvOzq3CmIlCWBl86/1aVg4OLoV/jLG5nwI/FbByCsCMZRslRlkjGf 9QQmBHD7uFBtumIyPhYBaI+jKIkMnrtw9mdtm2VKXsZpG5+8DDcSbsIZayal3KOjcbsgOdKq2Gj bggmtBmxbQpAXc+Ryu4yhj8xjDoCkLfC73TELMOON3TVHzYOdDVUN4I1pp85NPZtQstDrM8QVPY Pe2buQ3Vt3pnoqP2cYxS2bEvD39bMT+aspSadkeFTeKCpIr3LMqEIMA2CW7pytsOsSWX1Iz/XtY LyZvhWhGnFVYK4LFIMc4helOKXX9pF8gZbW/0sbh2qisG1PSS85e3IzJBrhFGKk/a96nfXGkfIH s4D9+42BQNkqnVXD1vlV6ANfA8nqWC97hrVgKFmDoeH/RNFd51CLwqnCfML3Hsu05UnY243WX0f DmsWeeOA0l3hDssClmoalHb4D/9v/GThXeAuEdUKowrgnIE1e02u7xorNnSA== X-Received: by 2002:a05:6a20:9f96:b0:3bf:bde7:d679 with SMTP id adf61e73a8af0-3c03e572be8mr3434759637.40.1783171457641; Sat, 04 Jul 2026 06:24:17 -0700 (PDT) Received: from smtpclient.apple ([2601:642:4c02:2196:b51d:3fa9:4ef4:ced1]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b3c7ef5b3sm44455057c88.1.2026.07.04.06.24.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jul 2026 06:24:16 -0700 (PDT) From: Chao Li Message-Id: <9FFB81DF-3F7F-42B5-915D-904F22B508C1@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_C5636D39-ED87-4F10-9581-5ACA177AD8A4" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: postgres_fdw: fix cumulative stats after imported foreign-table stats Date: Sat, 4 Jul 2026 06:23:45 -0700 In-Reply-To: Cc: PostgreSQL Hackers , Corey Huinker To: Etsuro Fujita References: <6ED81190-B398-44C9-A1E9-8EFE4ED183AF@gmail.com> X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_C5636D39-ED87-4F10-9581-5ACA177AD8A4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 3, 2026, at 02:10, Etsuro Fujita = wrote: >=20 > Hi Chao, >=20 > On Fri, Jun 12, 2026 at 12:49=E2=80=AFPM Chao Li = wrote: >> I think the root cause is that, with 28972b6fc, when stats are = imported successfully for a foreign table, do_analyze_rel() is skipped. = But do_analyze_rel() is the only place that calls = pgstat_report_analyze() to update cumulative stats. >>=20 >> To fix this, I think we need to add an output parameter to = ImportForeignStatistics to pass out total live rows. AFAIK, the imported = remote relation stats have no dead-tuple estimate, so analyze_rel() can = pass 0 as the dead-tuple estimate when calling pgstat_report_analyze(). = That gives us the needed data to call pgstat_report_analyze() after a = successful import. >=20 > The root-cause analysis is correct, but I don't think that the fix is > the right way to go, because if we modified pgstat_report_analyze() to > report more ANALYZE stats, we would need to modify the > ImportForeignStatistics API as well, which isn't great. To avoid > that, how about calling pgstat_report_analyze() in > postgresImportForeignStatistics(), like the attached? (Actually, I > designed the API as something we entirely replace do_analyze_rel() > with.) I modified the test case as well. >=20 > Sorry for the delay. >=20 > Best regards, > Etsuro Fujita > Hi Etsuro-san, Thanks for your review and for proposing an alternative fix. I thought postgres_fdw was where we interact with the remote server, = while analyze_rel() is the code deciding that ANALYZE succeeded. = Ideally, cumulative ANALYZE reporting would be driven from that level, = not from an FDW callback implementation. But I understand your concern about changing the ImportForeignStatistics = API, so I=E2=80=99m fine with your proposal. I have integrated your = changes into v2. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_C5636D39-ED87-4F10-9581-5ACA177AD8A4 Content-Disposition: attachment; filename=v2-0001-Fix-ANALYZE-reporting-after-imported-foreign-tabl.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v2-0001-Fix-ANALYZE-reporting-after-imported-foreign-tabl.patch" Content-Transfer-Encoding: quoted-printable =46rom=202c2f0e6253e0f57e88793619f3e83babf186ef4f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Fri,=2012=20Jun=202026=2011:20:19=20+0800=0ASubject:=20[PATCH=20= v2]=20Fix=20ANALYZE=20reporting=20after=20imported=20foreign-table=20= stats=0A=0ACommit=2028972b6fc=20added=20the=20ImportForeignStatistics=20= FDW=20callback,=20which=0Alets=20ANALYZE=20import=20remote=20statistics=20= instead=20of=20sampling=20a=20foreign=20table.=0AWhen=20that=20path=20= succeeds,=20analyze_rel()=20skips=20do_analyze_rel().=20That=20also=0A= skips=20pgstat_report_analyze(),=20so=20cumulative=20ANALYZE=20stats=20= such=20as=0Aanalyze_count,=20last_analyze_time,=20and=20live_tuples=20= are=20not=20updated=20even=0Athough=20ANALYZE=20succeeded.=0A=0AFix=20by=20= having=20postgres_fdw=20report=20ANALYZE=20to=20the=20cumulative=20stats=20= system=0Aafter=20a=20successful=20statistics=20import.=20The=20imported=20= live-row=20estimate=20comes=0Afrom=20the=20remote=20reltuples=20value.=20= Since=20imported=20relation=20stats=20do=20not=0Ainclude=20a=20= dead-tuple=20estimate,=20report=20zero=20dead=20tuples=20for=20this=20= path.=0A=0AAdd=20regression=20coverage=20for=20postgres_fdw=20stats=20= import=20to=20verify=20that=20a=0Asuccessful=20imported=20ANALYZE=20= updates=20live_tuples=20and=20analyze_count.=0A=0AAuthor:=20Chao=20Li=20= =0AReported-by:=20Chao=20Li=20=0A= Reviewed-by:=20Etsuro=20Fujita=20=0ADiscussion:=20= https://postgr.es/m/6ED81190-B398-44C9-A1E9-8EFE4ED183AF@gmail.com=0A---=0A= =20.../postgres_fdw/expected/postgres_fdw.out=20=20=20=20|=2040=20= +++++++++++++++++++=0A=20contrib/postgres_fdw/postgres_fdw.c=20=20=20=20=20= =20=20=20=20=20=20|=2017=20++++++++=0A=20= contrib/postgres_fdw/sql/postgres_fdw.sql=20=20=20=20=20|=2010=20+++++=0A= =20src/backend/commands/analyze.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20|=20=203=20+-=0A=204=20files=20changed,=2069=20insertions(+),=201=20= deletion(-)=0A=0Adiff=20--git=20= a/contrib/postgres_fdw/expected/postgres_fdw.out=20= b/contrib/postgres_fdw/expected/postgres_fdw.out=0Aindex=20= 0805c56cb1b..5ebae1cedc2=20100644=0A---=20= a/contrib/postgres_fdw/expected/postgres_fdw.out=0A+++=20= b/contrib/postgres_fdw/expected/postgres_fdw.out=0A@@=20-12973,9=20= +12973,29=20@@=20ALTER=20FOREIGN=20TABLE=20simport_ftable=20OPTIONS=20= (ADD=20restore_stats=20'true');=0A=20ANALYZE=20simport_ftable;=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20--=20should=20fail=0A=20= WARNING:=20=20could=20not=20import=20statistics=20for=20foreign=20table=20= "public.simport_ftable"=20---=20remote=20table=20"public.simport_table"=20= has=20no=20relation=20statistics=20to=20import=0A=20ANALYZE=20= simport_table;=0A+SELECT=20= pg_stat_reset_single_table_counters('public.simport_ftable'::regclass);=0A= +=20pg_stat_reset_single_table_counters=20=0A= +-------------------------------------=0A+=20=0A+(1=20row)=0A+=0A=20= ANALYZE=20VERBOSE=20simport_ftable;=20=20=20=20=20=20=20=20=20=20=20--=20= should=20work=0A=20INFO:=20=20importing=20statistics=20for=20foreign=20= table=20"public.simport_ftable"=0A=20INFO:=20=20finished=20importing=20= statistics=20for=20foreign=20table=20"public.simport_ftable"=0A+SELECT=20= pg_stat_force_next_flush();=0A+=20pg_stat_force_next_flush=20=0A= +--------------------------=0A+=20=0A+(1=20row)=0A+=0A+SELECT=20= pg_stat_get_live_tuples('public.simport_ftable'::regclass),=0A+=20=20=20=20= =20=20=20pg_stat_get_dead_tuples('public.simport_ftable'::regclass),=0A+=20= =20=20=20=20=20=20= pg_stat_get_analyze_count('public.simport_ftable'::regclass);=0A+=20= pg_stat_get_live_tuples=20|=20pg_stat_get_dead_tuples=20|=20= pg_stat_get_analyze_count=20=0A= +-------------------------+-------------------------+---------------------= ------=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=200=20|=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=200=20|=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=201=0A+(1=20row)=0A+=0A=20ALTER=20TABLE=20simport_table=20= ALTER=20COLUMN=20c1=20SET=20STATISTICS=200;=0A=20ALTER=20TABLE=20= simport_table=20ALTER=20COLUMN=20c2=20SET=20STATISTICS=200;=0A=20INSERT=20= INTO=20simport_table=20VALUES=20(1,=20'foo'),=20(1,=20'foo'),=20(2,=20= 'bar'),=20(2,=20'bar');=0A@@=20-12988,9=20+13008,29=20@@=20ANALYZE=20= simport_ftable;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= --=20should=20fail=0A=20WARNING:=20=20could=20not=20import=20statistics=20= for=20foreign=20table=20"public.simport_ftable"=20---=20no=20attribute=20= statistics=20found=20for=20column=20"c2"=20of=20remote=20table=20= "public.simport_table"=0A=20ALTER=20TABLE=20simport_table=20ALTER=20= COLUMN=20c2=20SET=20STATISTICS=20DEFAULT;=0A=20ANALYZE=20simport_table;=0A= +SELECT=20= pg_stat_reset_single_table_counters('public.simport_ftable'::regclass);=0A= +=20pg_stat_reset_single_table_counters=20=0A= +-------------------------------------=0A+=20=0A+(1=20row)=0A+=0A=20= ANALYZE=20VERBOSE=20simport_ftable;=20=20=20=20=20=20=20=20=20=20=20--=20= should=20work=0A=20INFO:=20=20importing=20statistics=20for=20foreign=20= table=20"public.simport_ftable"=0A=20INFO:=20=20finished=20importing=20= statistics=20for=20foreign=20table=20"public.simport_ftable"=0A+SELECT=20= pg_stat_force_next_flush();=0A+=20pg_stat_force_next_flush=20=0A= +--------------------------=0A+=20=0A+(1=20row)=0A+=0A+SELECT=20= pg_stat_get_live_tuples('public.simport_ftable'::regclass),=0A+=20=20=20=20= =20=20=20pg_stat_get_dead_tuples('public.simport_ftable'::regclass),=0A+=20= =20=20=20=20=20=20= pg_stat_get_analyze_count('public.simport_ftable'::regclass);=0A+=20= pg_stat_get_live_tuples=20|=20pg_stat_get_dead_tuples=20|=20= pg_stat_get_analyze_count=20=0A= +-------------------------+-------------------------+---------------------= ------=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=204=20|=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=200=20|=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=201=0A+(1=20row)=0A+=0A=20ANALYZE=20VERBOSE=20simport_ftable=20= (c1);=20=20=20=20=20=20--=20should=20work=0A=20INFO:=20=20importing=20= statistics=20for=20foreign=20table=20"public.simport_ftable"=0A=20INFO:=20= =20finished=20importing=20statistics=20for=20foreign=20table=20= "public.simport_ftable"=0Adiff=20--git=20= a/contrib/postgres_fdw/postgres_fdw.c=20= b/contrib/postgres_fdw/postgres_fdw.c=0Aindex=206fa45773c30..e5917eb7449=20= 100644=0A---=20a/contrib/postgres_fdw/postgres_fdw.c=0A+++=20= b/contrib/postgres_fdw/postgres_fdw.c=0A@@=20-41,6=20+41,7=20@@=0A=20= #include=20"optimizer/restrictinfo.h"=0A=20#include=20= "optimizer/tlist.h"=0A=20#include=20"parser/parsetree.h"=0A+#include=20= "pgstat.h"=0A=20#include=20"postgres_fdw.h"=0A=20#include=20= "statistics/statistics.h"=0A=20#include=20"storage/latch.h"=0A@@=20-52,6=20= +53,7=20@@=0A=20#include=20"utils/rel.h"=0A=20#include=20= "utils/sampling.h"=0A=20#include=20"utils/selfuncs.h"=0A+#include=20= "utils/timestamp.h"=0A=20=0A=20PG_MODULE_MAGIC_EXT(=0A=20=09=09=09=09=09= .name=20=3D=20"postgres_fdw",=0A@@=20-336,6=20+338,8=20@@=20typedef=20= struct=0A=20=09PGresult=20=20=20*rel;=0A=20=09PGresult=20=20=20*att;=0A=20= =09int=09=09=09server_version_num;=0A+=09double=09=09livetuples;=0A+=09= double=09=09deadtuples;=0A=20}=20RemoteStatsResults;=0A=20=0A=20/*=20= Column=20order=20in=20relation=20stats=20query=20*/=0A@@=20-5597,6=20= +5601,7=20@@=20postgresImportForeignStatistics(Relation=20relation,=20= List=20*va_cols,=20int=20elevel)=0A=20=09RemoteStatsResults=20remstats=20= =3D=20{.rel=20=3D=20NULL,=20.att=20=3D=20NULL};=0A=20=09= RemoteAttributeMapping=20*remattrmap=20=3D=20NULL;=0A=20=09int=09=09=09= attrcnt=20=3D=200;=0A+=09TimestampTz=20starttime=20=3D=200;=0A=20=09bool=09= =09restore_stats=20=3D=20false;=0A=20=09bool=09=09ok=20=3D=20false;=0A=20= =09ListCell=20=20=20*lc;=0A@@=20-5656,6=20+5661,8=20@@=20= postgresImportForeignStatistics(Relation=20relation,=20List=20*va_cols,=20= int=20elevel)=0A=20=09=09=09(errmsg("importing=20statistics=20for=20= foreign=20table=20\"%s.%s\"",=0A=20=09=09=09=09=09schemaname,=20= relname)));=0A=20=0A+=09starttime=20=3D=20GetCurrentTimestamp();=0A+=0A=20= =09ok=20=3D=20fetch_remote_statistics(relation,=20va_cols,=0A=20=09=09=09= =09=09=09=09=09=20table,=20schemaname,=20relname,=0A=20=09=09=09=09=09=09= =09=09=20&attrcnt,=20&remattrmap,=20&remstats);=0A@@=20-5665,9=20= +5672,15=20@@=20postgresImportForeignStatistics(Relation=20relation,=20= List=20*va_cols,=20int=20elevel)=0A=20=09=09=09=09=09=09=09=09=09=20=20=20= attrcnt,=20remattrmap,=20&remstats);=0A=20=0A=20=09if=20(ok)=0A+=09{=0A+=09= =09pgstat_report_analyze(relation,=0A+=09=09=09=09=09=09=09=20=20= remstats.livetuples,=20remstats.deadtuples,=0A+=09=09=09=09=09=09=09=20=20= (va_cols=20=3D=3D=20NIL),=20starttime);=0A+=0A=20=09=09ereport(elevel,=0A= =20=09=09=09=09(errmsg("finished=20importing=20statistics=20for=20= foreign=20table=20\"%s.%s\"",=0A=20=09=09=09=09=09=09schemaname,=20= relname)));=0A+=09}=0A=20=0A=20=09PQclear(remstats.rel);=0A=20=09= PQclear(remstats.att);=0A@@=20-5807,6=20+5820,10=20@@=20= fetch_remote_statistics(Relation=20relation,=0A=20=09=09}=0A=20=09}=0A=20= =0A+=09/*=20We=20assume=20that=20we=20have=20no=20dead=20tuple.=20*/=0A+=09= remstats->deadtuples=20=3D=200.0;=0A+=09remstats->livetuples=20=3D=20= reltuples;=0A+=0A=20=09ok=20=3D=20true;=0A=20=0A=20fetch_cleanup:=0Adiff=20= --git=20a/contrib/postgres_fdw/sql/postgres_fdw.sql=20= b/contrib/postgres_fdw/sql/postgres_fdw.sql=0Aindex=20= 8162c5496bf..e868da00ace=20100644=0A---=20= a/contrib/postgres_fdw/sql/postgres_fdw.sql=0A+++=20= b/contrib/postgres_fdw/sql/postgres_fdw.sql=0A@@=20-4587,7=20+4587,12=20= @@=20ANALYZE=20simport_ftable;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20--=20should=20fail=0A=20=0A=20ANALYZE=20simport_table;=0A=20=0A= +SELECT=20= pg_stat_reset_single_table_counters('public.simport_ftable'::regclass);=0A= =20ANALYZE=20VERBOSE=20simport_ftable;=20=20=20=20=20=20=20=20=20=20=20= --=20should=20work=0A+SELECT=20pg_stat_force_next_flush();=0A+SELECT=20= pg_stat_get_live_tuples('public.simport_ftable'::regclass),=0A+=20=20=20=20= =20=20=20pg_stat_get_dead_tuples('public.simport_ftable'::regclass),=0A+=20= =20=20=20=20=20=20= pg_stat_get_analyze_count('public.simport_ftable'::regclass);=0A=20=0A=20= ALTER=20TABLE=20simport_table=20ALTER=20COLUMN=20c1=20SET=20STATISTICS=20= 0;=0A=20ALTER=20TABLE=20simport_table=20ALTER=20COLUMN=20c2=20SET=20= STATISTICS=200;=0A@@=20-4604,7=20+4609,12=20@@=20ANALYZE=20= simport_ftable;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= --=20should=20fail=0A=20ALTER=20TABLE=20simport_table=20ALTER=20COLUMN=20= c2=20SET=20STATISTICS=20DEFAULT;=0A=20ANALYZE=20simport_table;=0A=20=0A= +SELECT=20= pg_stat_reset_single_table_counters('public.simport_ftable'::regclass);=0A= =20ANALYZE=20VERBOSE=20simport_ftable;=20=20=20=20=20=20=20=20=20=20=20= --=20should=20work=0A+SELECT=20pg_stat_force_next_flush();=0A+SELECT=20= pg_stat_get_live_tuples('public.simport_ftable'::regclass),=0A+=20=20=20=20= =20=20=20pg_stat_get_dead_tuples('public.simport_ftable'::regclass),=0A+=20= =20=20=20=20=20=20= pg_stat_get_analyze_count('public.simport_ftable'::regclass);=0A=20=0A=20= ANALYZE=20VERBOSE=20simport_ftable=20(c1);=20=20=20=20=20=20--=20should=20= work=0A=20=0Adiff=20--git=20a/src/backend/commands/analyze.c=20= b/src/backend/commands/analyze.c=0Aindex=20f66e80b757c..2edd88087f5=20= 100644=0A---=20a/src/backend/commands/analyze.c=0A+++=20= b/src/backend/commands/analyze.c=0A@@=20-230,7=20+230,8=20@@=20= analyze_rel(Oid=20relid,=20RangeVar=20*relation,=0A=20=09=09if=20= (fdwroutine->ImportForeignStatistics=20!=3D=20NULL=20&&=0A=20=09=09=09= fdwroutine->ImportForeignStatistics(onerel,=20va_cols,=20elevel))=0A=20=09= =09=09stats_imported=20=3D=20true;=0A-=09=09else=0A+=0A+=09=09if=20= (!stats_imported)=0A=20=09=09{=0A=20=09=09=09bool=09=09ok=20=3D=20false;=0A= =20=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_C5636D39-ED87-4F10-9581-5ACA177AD8A4--