Temporarily instrument postgres_fdw test to look for statistics changes.
authorTom Lane <[email protected]>
Mon, 5 Mar 2018 21:20:06 +0000 (16:20 -0500)
committerTom Lane <[email protected]>
Mon, 5 Mar 2018 21:20:06 +0000 (16:20 -0500)
It seems fairly hard to explain recent buildfarm failures without the
theory that something is doing an ANALYZE behind our backs.  Probe
for this directly to see if it's true.

In principle the outputs of these queries should be stable, since the table
in question is small enough that ANALYZE's sample will include all rows.
But even if that turns out to be wrong, we can put up with some failures
for a bit.  I don't intend to leave this here indefinitely.

Discussion: https://postgr.es/m/25502.1520277552@sss.pgh.pa.us

contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/sql/postgres_fdw.sql

index a2b13846e0f0dafb3b46615239055df9dd4704ad..cbb5daa239075498d2d555cd07094d23613f743b 100644 (file)
@@ -87,6 +87,23 @@ ANALYZE "S 1"."T 1";
 ANALYZE "S 1"."T 2";
 ANALYZE "S 1"."T 3";
 ANALYZE "S 1"."T 4";
+-- record relpages for T 1
+create temp table save_t_1_relpages as
+  select relpages as old_relpages from pg_class where relname = 'T 1';
+select relpages - (select old_relpages from save_t_1_relpages) as pg_delta,
+  reltuples from pg_class where relname = 'T 1';
+ pg_delta | reltuples 
+----------+-----------
+        0 |      1000
+(1 row)
+
+select (histogram_bounds::text::int[])[array_length(histogram_bounds,1)]
+  from pg_stats where tablename = 'T 1' and attname = 'C 1';
+ histogram_bounds 
+------------------
+             1000
+(1 row)
+
 -- ===================================================================
 -- create foreign tables
 -- ===================================================================
@@ -5520,6 +5537,20 @@ UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *;
  2010 |  0 | bar |    |    |    | ft2        | 
 (10 rows)
 
+select relpages - (select old_relpages from save_t_1_relpages) as pg_delta,
+  reltuples from pg_class where relname = 'T 1';
+ pg_delta | reltuples 
+----------+-----------
+        0 |      1000
+(1 row)
+
+select (histogram_bounds::text::int[])[array_length(histogram_bounds,1)]
+  from pg_stats where tablename = 'T 1' and attname = 'C 1';
+ histogram_bounds 
+------------------
+             1000
+(1 row)
+
 EXPLAIN (verbose, costs off)
 UPDATE ft2 SET c3 = 'baz'
   FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1)
index 4d2e43c9f0594cd1e6adef8a3f68c22049e215d0..8b1407b959a020800e0310110e26c07e6975e4d2 100644 (file)
@@ -95,6 +95,15 @@ ANALYZE "S 1"."T 2";
 ANALYZE "S 1"."T 3";
 ANALYZE "S 1"."T 4";
 
+-- record relpages for T 1
+create temp table save_t_1_relpages as
+  select relpages as old_relpages from pg_class where relname = 'T 1';
+
+select relpages - (select old_relpages from save_t_1_relpages) as pg_delta,
+  reltuples from pg_class where relname = 'T 1';
+select (histogram_bounds::text::int[])[array_length(histogram_bounds,1)]
+  from pg_stats where tablename = 'T 1' and attname = 'C 1';
+
 -- ===================================================================
 -- create foreign tables
 -- ===================================================================
@@ -1139,6 +1148,10 @@ INSERT INTO ft2 (c1,c2,c3)
 EXPLAIN (verbose, costs off)
 UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *;            -- can't be pushed down
 UPDATE ft2 SET c3 = 'bar' WHERE postgres_fdw_abs(c1) > 2000 RETURNING *;
+select relpages - (select old_relpages from save_t_1_relpages) as pg_delta,
+  reltuples from pg_class where relname = 'T 1';
+select (histogram_bounds::text::int[])[array_length(histogram_bounds,1)]
+  from pg_stats where tablename = 'T 1' and attname = 'C 1';
 EXPLAIN (verbose, costs off)
 UPDATE ft2 SET c3 = 'baz'
   FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1)