@@ -628,6 +628,7 @@ INSERT INTO loct_empty
628628 SELECT id, 'AAA' || to_char(id, 'FM000') FROM generate_series(1, 100) id;
629629DELETE FROM loct_empty;
630630ANALYZE ft_empty;
631+ INFO: Found no remote statistics for "ft_empty"
631632EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft_empty ORDER BY c1;
632633 QUERY PLAN
633634-------------------------------------------------------------------------------
@@ -4551,7 +4552,8 @@ REINDEX TABLE reind_fdw_parent; -- ok
45514552REINDEX TABLE CONCURRENTLY reind_fdw_parent; -- ok
45524553DROP TABLE reind_fdw_parent;
45534554-- ===================================================================
4554- -- conversion error
4555+ -- conversion error, will generate a WARNING for imported stats and an
4556+ -- error on locally computed stats.
45554557-- ===================================================================
45564558ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE int;
45574559SELECT * FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8) WHERE x1 = 1; -- ERROR
@@ -4568,6 +4570,9 @@ CONTEXT: whole-row reference to foreign table "ftx"
45684570SELECT sum(c2), array_agg(c8) FROM ft1 GROUP BY c8; -- ERROR
45694571ERROR: invalid input syntax for type integer: "foo"
45704572CONTEXT: processing expression at position 2 in select list
4573+ ANALYZE ft1; -- WARNING
4574+ WARNING: invalid input syntax for type integer: "foo"
4575+ ALTER FOREIGN TABLE ft1 OPTIONS ( fetch_stats 'false' );
45714576ANALYZE ft1; -- ERROR
45724577ERROR: invalid input syntax for type integer: "foo"
45734578CONTEXT: column "c8" of foreign table "ft1"
@@ -7102,6 +7107,7 @@ INSERT INTO loct2 VALUES (1002, 'bar');
71027107CREATE FOREIGN TABLE remt2 (c1 int, c2 text) SERVER loopback OPTIONS (table_name 'loct2');
71037108ANALYZE loct1;
71047109ANALYZE remt2;
7110+ INFO: Found no remote statistics for "remt2"
71057111SET enable_mergejoin TO false;
71067112SET enable_hashjoin TO false;
71077113SET enable_material TO false;
@@ -8784,6 +8790,7 @@ alter foreign table foo2 options (use_remote_estimate 'true');
87848790create index i_loct1_f1 on loct1(f1);
87858791create index i_foo_f1 on foo(f1);
87868792analyze foo;
8793+ INFO: Found no remote statistics for "foo2"
87878794analyze loct1;
87888795-- inner join; expressions in the clauses appear in the equivalence class list
87898796explain (verbose, costs off)
@@ -9013,7 +9020,9 @@ insert into remt1 values (2, 'bar');
90139020insert into remt2 values (1, 'foo');
90149021insert into remt2 values (2, 'bar');
90159022analyze remt1;
9023+ INFO: Found no remote statistics for "remt1"
90169024analyze remt2;
9025+ INFO: Found no remote statistics for "remt2"
90179026explain (verbose, costs off)
90189027update parent set b = parent.b || remt2.b from remt2 where parent.a = remt2.a returning *;
90199028 QUERY PLAN
@@ -10313,6 +10322,8 @@ CREATE FOREIGN TABLE ftprt1_p1 PARTITION OF fprt1 FOR VALUES FROM (0) TO (250)
1031310322CREATE FOREIGN TABLE ftprt1_p2 PARTITION OF fprt1 FOR VALUES FROM (250) TO (500)
1031410323 SERVER loopback OPTIONS (TABLE_NAME 'fprt1_p2');
1031510324ANALYZE fprt1;
10325+ INFO: Found no remote statistics for "ftprt1_p1"
10326+ INFO: Found no remote statistics for "ftprt1_p2"
1031610327ANALYZE fprt1_p1;
1031710328ANALYZE fprt1_p2;
1031810329CREATE TABLE fprt2 (a int, b int, c varchar) PARTITION BY RANGE(b);
@@ -10328,6 +10339,8 @@ ALTER TABLE fprt2 ATTACH PARTITION ftprt2_p1 FOR VALUES FROM (0) TO (250);
1032810339CREATE FOREIGN TABLE ftprt2_p2 PARTITION OF fprt2 FOR VALUES FROM (250) TO (500)
1032910340 SERVER loopback OPTIONS (table_name 'fprt2_p2', use_remote_estimate 'true');
1033010341ANALYZE fprt2;
10342+ INFO: Found no remote statistics for "ftprt2_p1"
10343+ INFO: Found no remote statistics for "ftprt2_p2"
1033110344ANALYZE fprt2_p1;
1033210345ANALYZE fprt2_p2;
1033310346-- inner join three tables
@@ -10515,9 +10528,15 @@ CREATE FOREIGN TABLE fpagg_tab_p1 PARTITION OF pagg_tab FOR VALUES FROM (0) TO (
1051510528CREATE FOREIGN TABLE fpagg_tab_p2 PARTITION OF pagg_tab FOR VALUES FROM (10) TO (20) SERVER loopback OPTIONS (table_name 'pagg_tab_p2');
1051610529CREATE FOREIGN TABLE fpagg_tab_p3 PARTITION OF pagg_tab FOR VALUES FROM (20) TO (30) SERVER loopback OPTIONS (table_name 'pagg_tab_p3');
1051710530ANALYZE pagg_tab;
10531+ INFO: Found no remote statistics for "fpagg_tab_p1"
10532+ INFO: Found no remote statistics for "fpagg_tab_p2"
10533+ INFO: Found no remote statistics for "fpagg_tab_p3"
1051810534ANALYZE fpagg_tab_p1;
10535+ INFO: Found no remote statistics for "fpagg_tab_p1"
1051910536ANALYZE fpagg_tab_p2;
10537+ INFO: Found no remote statistics for "fpagg_tab_p2"
1052010538ANALYZE fpagg_tab_p3;
10539+ INFO: Found no remote statistics for "fpagg_tab_p3"
1052110540-- When GROUP BY clause matches with PARTITION KEY.
1052210541-- Plan with partitionwise aggregates is disabled
1052310542SET enable_partitionwise_aggregate TO false;
@@ -11463,6 +11482,8 @@ CREATE FOREIGN TABLE async_p2 PARTITION OF async_pt FOR VALUES FROM (2000) TO (3
1146311482INSERT INTO async_p1 SELECT 1000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i;
1146411483INSERT INTO async_p2 SELECT 2000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i;
1146511484ANALYZE async_pt;
11485+ INFO: Found no remote statistics for "async_p1"
11486+ INFO: Found no remote statistics for "async_p2"
1146611487-- simple queries
1146711488CREATE TABLE result_tbl (a int, b int, c text);
1146811489EXPLAIN (VERBOSE, COSTS OFF)
@@ -11569,6 +11590,9 @@ CREATE FOREIGN TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO (4
1156911590 SERVER loopback2 OPTIONS (table_name 'base_tbl3');
1157011591INSERT INTO async_p3 SELECT 3000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i;
1157111592ANALYZE async_pt;
11593+ INFO: Found no remote statistics for "async_p1"
11594+ INFO: Found no remote statistics for "async_p2"
11595+ INFO: Found no remote statistics for "async_p3"
1157211596EXPLAIN (VERBOSE, COSTS OFF)
1157311597INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505;
1157411598 QUERY PLAN
@@ -11610,6 +11634,8 @@ DROP TABLE base_tbl3;
1161011634CREATE TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO (4000);
1161111635INSERT INTO async_p3 SELECT 3000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i;
1161211636ANALYZE async_pt;
11637+ INFO: Found no remote statistics for "async_p1"
11638+ INFO: Found no remote statistics for "async_p2"
1161311639EXPLAIN (VERBOSE, COSTS OFF)
1161411640INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505;
1161511641 QUERY PLAN
@@ -12665,6 +12691,42 @@ ANALYZE analyze_ftable;
1266512691DROP FOREIGN TABLE analyze_ftable;
1266612692DROP TABLE analyze_table;
1266712693-- ===================================================================
12694+ -- test remote analyze
12695+ -- ===================================================================
12696+ CREATE TABLE remote_analyze_table (id int, a text, b bigint);
12697+ INSERT INTO remote_analyze_table (SELECT x FROM generate_series(1,1000) x);
12698+ CREATE FOREIGN TABLE remote_analyze_ftable (id int, a text, b bigint)
12699+ SERVER loopback
12700+ OPTIONS (table_name 'remote_analyze_table', remote_analyze 'true');
12701+ -- no stats before
12702+ SELECT s.tablename, COUNT(*) AS num_stats
12703+ FROM pg_stats AS s
12704+ WHERE s.schemaname = 'public'
12705+ AND s.tablename IN ('remote_analyze_table', 'remote_analyze_ftable')
12706+ GROUP BY s.tablename
12707+ ORDER BY s.tablename;
12708+ tablename | num_stats
12709+ -----------+-----------
12710+ (0 rows)
12711+
12712+ ANALYZE remote_analyze_ftable;
12713+ -- both stats after
12714+ SELECT s.tablename, COUNT(*) AS num_stats
12715+ FROM pg_stats AS s
12716+ WHERE s.schemaname = 'public'
12717+ AND s.tablename IN ('remote_analyze_table', 'remote_analyze_ftable')
12718+ GROUP BY s.tablename
12719+ ORDER BY s.tablename;
12720+ tablename | num_stats
12721+ -----------------------+-----------
12722+ remote_analyze_ftable | 3
12723+ remote_analyze_table | 3
12724+ (2 rows)
12725+
12726+ -- cleanup
12727+ DROP FOREIGN TABLE remote_analyze_ftable;
12728+ DROP TABLE remote_analyze_table;
12729+ -- ===================================================================
1266812730-- test for postgres_fdw_get_connections function with check_conn = true
1266912731-- ===================================================================
1267012732-- Disable debug_discard_caches in order to manage remote connections
0 commit comments