Skip to content

Commit 4fa3964

Browse files
committed
postgres_fdw: Third attempt to stabilize regression tests.
Commit 1bc0100 added this test, and commit 882ea50 tried to stabilize it. There were still failures, so commit 958e20e tried again to stabilize it. That approach is still failing on jaguarundi, though, so back it out and try something else. Specifically, instead of disabling remote estimates for the table in question, let's tell autovacuum to leave it alone. Etsuro Fujita Discussion: http://postgr.es/m/[email protected]
1 parent c161ea1 commit 4fa3964

File tree

2 files changed

+24
-31
lines changed

2 files changed

+24
-31
lines changed

contrib/postgres_fdw/expected/postgres_fdw.out

+21-24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ CREATE TABLE "S 1"."T 1" (
3535
c8 user_enum,
3636
CONSTRAINT t1_pkey PRIMARY KEY ("C 1")
3737
);
38+
-- "S 1"."T 1" will be heavily updated below, so disable autovacuum for
39+
-- the table to avoid unexpected effects of that
40+
ALTER TABLE "S 1"."T 1" SET (autovacuum_enabled = 'false');
3841
CREATE TABLE "S 1"."T 2" (
3942
c1 int NOT NULL,
4043
c2 text,
@@ -4244,10 +4247,6 @@ explain (verbose, costs off) select * from ft3 f, loct3 l
42444247
-- ===================================================================
42454248
-- test writable foreign table stuff
42464249
-- ===================================================================
4247-
-- Autovacuum on the remote side might affect remote estimates,
4248-
-- so use local stats on ft2 as well
4249-
ALTER FOREIGN TABLE ft2 OPTIONS (SET use_remote_estimate 'false');
4250-
ANALYZE ft2;
42514250
EXPLAIN (verbose, costs off)
42524251
INSERT INTO ft2 (c1,c2,c3) SELECT c1+1000,c2+100, c3 || c3 FROM ft2 LIMIT 20;
42534252
QUERY PLAN
@@ -5524,32 +5523,32 @@ UPDATE ft2 SET c3 = 'baz'
55245523
FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1)
55255524
WHERE ft2.c1 > 2000 AND ft2.c2 === ft4.c1
55265525
RETURNING ft2.*, ft4.*, ft5.*; -- can't be pushed down
5527-
QUERY PLAN
5528-
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
5526+
QUERY PLAN
5527+
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
55295528
Update on public.ft2
55305529
Output: ft2.c1, ft2.c2, ft2.c3, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft4.c1, ft4.c2, ft4.c3, ft5.c1, ft5.c2, ft5.c3
55315530
Remote SQL: UPDATE "S 1"."T 1" SET c3 = $2 WHERE ctid = $1 RETURNING "C 1", c2, c3, c4, c5, c6, c7, c8
5532-
-> Hash Join
5531+
-> Nested Loop
55335532
Output: ft2.c1, ft2.c2, NULL::integer, 'baz'::text, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.ctid, ft4.*, ft5.*, ft4.c1, ft4.c2, ft4.c3, ft5.c1, ft5.c2, ft5.c3
5534-
Hash Cond: (ft4.c1 = ft5.c1)
5533+
Join Filter: (ft2.c2 === ft4.c1)
5534+
-> Foreign Scan on public.ft2
5535+
Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.ctid
5536+
Remote SQL: SELECT "C 1", c2, c4, c5, c6, c7, c8, ctid FROM "S 1"."T 1" WHERE (("C 1" > 2000)) FOR UPDATE
55355537
-> Foreign Scan
5536-
Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.ctid, ft4.*, ft4.c1, ft4.c2, ft4.c3
5537-
Filter: (ft2.c2 === ft4.c1)
5538-
Relations: (public.ft2) INNER JOIN (public.ft4)
5539-
Remote SQL: SELECT r1."C 1", r1.c2, r1.c4, r1.c5, r1.c6, r1.c7, r1.c8, r1.ctid, CASE WHEN (r2.*)::text IS NOT NULL THEN ROW(r2.c1, r2.c2, r2.c3) END, r2.c1, r2.c2, r2.c3 FROM ("S 1"."T 1" r1 INNER JOIN "S 1"."T 3" r2 ON (((r1."C 1" > 2000)))) FOR UPDATE OF r1
5540-
-> Nested Loop
5541-
Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.ctid, ft4.*, ft4.c1, ft4.c2, ft4.c3
5542-
-> Foreign Scan on public.ft2
5543-
Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.ctid
5544-
Remote SQL: SELECT "C 1", c2, c4, c5, c6, c7, c8, ctid FROM "S 1"."T 1" WHERE (("C 1" > 2000)) FOR UPDATE
5538+
Output: ft4.*, ft4.c1, ft4.c2, ft4.c3, ft5.*, ft5.c1, ft5.c2, ft5.c3
5539+
Relations: (public.ft4) INNER JOIN (public.ft5)
5540+
Remote SQL: SELECT CASE WHEN (r2.*)::text IS NOT NULL THEN ROW(r2.c1, r2.c2, r2.c3) END, r2.c1, r2.c2, r2.c3, CASE WHEN (r3.*)::text IS NOT NULL THEN ROW(r3.c1, r3.c2, r3.c3) END, r3.c1, r3.c2, r3.c3 FROM ("S 1"."T 3" r2 INNER JOIN "S 1"."T 4" r3 ON (((r2.c1 = r3.c1))))
5541+
-> Hash Join
5542+
Output: ft4.*, ft4.c1, ft4.c2, ft4.c3, ft5.*, ft5.c1, ft5.c2, ft5.c3
5543+
Hash Cond: (ft4.c1 = ft5.c1)
55455544
-> Foreign Scan on public.ft4
55465545
Output: ft4.*, ft4.c1, ft4.c2, ft4.c3
55475546
Remote SQL: SELECT c1, c2, c3 FROM "S 1"."T 3"
5548-
-> Hash
5549-
Output: ft5.*, ft5.c1, ft5.c2, ft5.c3
5550-
-> Foreign Scan on public.ft5
5551-
Output: ft5.*, ft5.c1, ft5.c2, ft5.c3
5552-
Remote SQL: SELECT c1, c2, c3 FROM "S 1"."T 4"
5547+
-> Hash
5548+
Output: ft5.*, ft5.c1, ft5.c2, ft5.c3
5549+
-> Foreign Scan on public.ft5
5550+
Output: ft5.*, ft5.c1, ft5.c2, ft5.c3
5551+
Remote SQL: SELECT c1, c2, c3 FROM "S 1"."T 4"
55535552
(24 rows)
55545553

55555554
UPDATE ft2 SET c3 = 'baz'
@@ -6003,9 +6002,7 @@ select c2, count(*) from "S 1"."T 1" where c2 < 500 group by 1 order by 1;
60036002
407 | 100
60046003
(13 rows)
60056004

6006-
-- Go back to use remote-estimate mode on ft2
60076005
VACUUM ANALYZE "S 1"."T 1";
6008-
ALTER FOREIGN TABLE ft2 OPTIONS (SET use_remote_estimate 'true');
60096006
-- Above DMLs add data with c6 as NULL in ft1, so test ORDER BY NULLS LAST and NULLs
60106007
-- FIRST behavior here.
60116008
-- ORDER BY DESC NULLS LAST options

contrib/postgres_fdw/sql/postgres_fdw.sql

+3-7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ CREATE TABLE "S 1"."T 1" (
3939
c8 user_enum,
4040
CONSTRAINT t1_pkey PRIMARY KEY ("C 1")
4141
);
42+
-- "S 1"."T 1" will be heavily updated below, so disable autovacuum for
43+
-- the table to avoid unexpected effects of that
44+
ALTER TABLE "S 1"."T 1" SET (autovacuum_enabled = 'false');
4245
CREATE TABLE "S 1"."T 2" (
4346
c1 int NOT NULL,
4447
c2 text,
@@ -1068,11 +1071,6 @@ explain (verbose, costs off) select * from ft3 f, loct3 l
10681071
-- ===================================================================
10691072
-- test writable foreign table stuff
10701073
-- ===================================================================
1071-
-- Autovacuum on the remote side might affect remote estimates,
1072-
-- so use local stats on ft2 as well
1073-
ALTER FOREIGN TABLE ft2 OPTIONS (SET use_remote_estimate 'false');
1074-
ANALYZE ft2;
1075-
10761074
EXPLAIN (verbose, costs off)
10771075
INSERT INTO ft2 (c1,c2,c3) SELECT c1+1000,c2+100, c3 || c3 FROM ft2 LIMIT 20;
10781076
INSERT INTO ft2 (c1,c2,c3) SELECT c1+1000,c2+100, c3 || c3 FROM ft2 LIMIT 20;
@@ -1213,9 +1211,7 @@ commit;
12131211
select c2, count(*) from ft2 where c2 < 500 group by 1 order by 1;
12141212
select c2, count(*) from "S 1"."T 1" where c2 < 500 group by 1 order by 1;
12151213

1216-
-- Go back to use remote-estimate mode on ft2
12171214
VACUUM ANALYZE "S 1"."T 1";
1218-
ALTER FOREIGN TABLE ft2 OPTIONS (SET use_remote_estimate 'true');
12191215

12201216
-- Above DMLs add data with c6 as NULL in ft1, so test ORDER BY NULLS LAST and NULLs
12211217
-- FIRST behavior here.

0 commit comments

Comments
 (0)