CREATE TABLE test(i int);
ALTER TABLE test SET (autovacuum_enabled = off);
INSERT INTO test
SELECT * FROM generate_series(1,1000);
-- With: Without any ANALYZE.
EXPLAIN
SELECT * FROM test WHERE i = 100;
ANALYZE test;
-- With: ANALYZE before index creation. Estimates adjusted.
EXPLAIN
SELECT * FROM test WHERE i = 100;
CREATE INDEX ON test(i);
-- With: After ANALYZE before index creation, but before ANALYZE after index creation.
EXPLAIN
SELECT * FROM test WHERE i = 100;
ANALYZE test;
-- With: ANALYZE after index creation => SAME as above.
EXPLAIN
SELECT * FROM test WHERE i = 100;