Temporary fix to get consistent results from ANALYZE
authorPavan Deolasee <[email protected]>
Thu, 18 Oct 2018 08:15:22 +0000 (13:45 +0530)
committerPavan Deolasee <[email protected]>
Thu, 18 Oct 2018 08:15:22 +0000 (13:45 +0530)
While we don't yet quite sure about the underlying problem, it seems that
sometimes ANALYZE fails to take into account recent updates. We suspect that
this happens because of the cluster monitor taking a little longer to report
xmin and update global xmin. For now, force a wait to get up to date stats.

src/test/regress/expected/inherit.out
src/test/regress/expected/updatable_views.out
src/test/regress/sql/inherit.sql
src/test/regress/sql/updatable_views.sql

index 4876a769e57b51c6a040afe8e44e4b0e7f3b9924..48e659a928e1e0179a4fad52e1e164a4700765e6 100644 (file)
@@ -1517,6 +1517,12 @@ insert into patest2
 create index patest0i on patest0(id);
 create index patest1i on patest1(id);
 create index patest2i on patest2(id);
+select pg_sleep(5);                    -- shame we need to do that
+ pg_sleep 
+----------
+(1 row)
+
 vacuum analyze patest0;
 vacuum analyze patest1;
 vacuum analyze patest2;
index a2a91a80f25c5d9919625d59acbea74b213ac542..3655085a49ab46a5b364fa9074cf67c5e1948871 100644 (file)
@@ -2038,21 +2038,18 @@ CREATE TABLE t1 (a int, b float, c text) DISTRIBUTE BY REPLICATION;
 CREATE INDEX t1_a_idx ON t1(a);
 INSERT INTO t1
 SELECT i,i,'t1' FROM generate_series(1,10) g(i);
-ANALYZE t1;
 CREATE TABLE t11 (d text) INHERITS (t1) DISTRIBUTE BY REPLICATION;
 WARNING:  Inherited/partition tables inherit distribution from the parent
 DETAIL:  Explicitly specified distribution will be ignored
 CREATE INDEX t11_a_idx ON t11(a);
 INSERT INTO t11
 SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i);
-ANALYZE t11;
 CREATE TABLE t12 (e int[]) INHERITS (t1) DISTRIBUTE BY REPLICATION;
 WARNING:  Inherited/partition tables inherit distribution from the parent
 DETAIL:  Explicitly specified distribution will be ignored
 CREATE INDEX t12_a_idx ON t12(a);
 INSERT INTO t12
 SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i);
-ANALYZE t12;
 CREATE TABLE t111 () INHERITS (t11, t12) DISTRIBUTE BY REPLICATION;
 WARNING:  Inherited/partition tables inherit distribution from the parent
 DETAIL:  Explicitly specified distribution will be ignored
@@ -2062,6 +2059,15 @@ NOTICE:  merging multiple inherited definitions of column "c"
 CREATE INDEX t111_a_idx ON t111(a);
 INSERT INTO t111
 SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i);
+SELECT pg_sleep(5);         -- shame we need to do that
+ pg_sleep 
+----------
+(1 row)
+
+ANALYZE t1;
+ANALYZE t11;
+ANALYZE t12;
 ANALYZE t111;
 CREATE VIEW v1 WITH (security_barrier=true) AS
 SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LIMIT 1) AS d
index 33121b0344cbca87d0e95a9c2d28b3a8c1636b4d..ac868fe54a8318880f04573b1c246e4c6013d2aa 100644 (file)
@@ -518,6 +518,8 @@ insert into patest2
 create index patest0i on patest0(id);
 create index patest1i on patest1(id);
 create index patest2i on patest2(id);
+
+select pg_sleep(5);                    -- shame we need to do that
 vacuum analyze patest0;
 vacuum analyze patest1;
 vacuum analyze patest2;
index 930bce6c04df73530a4dfed7125ab56617c02b8e..cb54c7411c7897d6a5d7ca106407ac4039ee228d 100644 (file)
@@ -972,24 +972,27 @@ CREATE TABLE t1 (a int, b float, c text) DISTRIBUTE BY REPLICATION;
 CREATE INDEX t1_a_idx ON t1(a);
 INSERT INTO t1
 SELECT i,i,'t1' FROM generate_series(1,10) g(i);
-ANALYZE t1;
 
 CREATE TABLE t11 (d text) INHERITS (t1) DISTRIBUTE BY REPLICATION;
 CREATE INDEX t11_a_idx ON t11(a);
 INSERT INTO t11
 SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i);
-ANALYZE t11;
 
 CREATE TABLE t12 (e int[]) INHERITS (t1) DISTRIBUTE BY REPLICATION;
 CREATE INDEX t12_a_idx ON t12(a);
 INSERT INTO t12
 SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i);
-ANALYZE t12;
 
 CREATE TABLE t111 () INHERITS (t11, t12) DISTRIBUTE BY REPLICATION;
 CREATE INDEX t111_a_idx ON t111(a);
 INSERT INTO t111
 SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i);
+
+SELECT pg_sleep(5);         -- shame we need to do that
+
+ANALYZE t1;
+ANALYZE t11;
+ANALYZE t12;
 ANALYZE t111;
 
 CREATE VIEW v1 WITH (security_barrier=true) AS