\timing on

CREATE TABLE t (a int, b int);
CREATE STATISTICS s (mcv) ON a, b FROM t;

TRUNCATE t;

INSERT INTO t SELECT 10*random(), 10*random() FROM generate_series(1,3000000) s(i);
VACUUM t;
CHECKPOINT;

SET default_statistics_target = 100;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 1000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 5000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 10000;

ANALYZE t;
ANALYZE t;
ANALYZE t;


TRUNCATE t;

INSERT INTO t SELECT 100*random(), 100*random() FROM generate_series(1,3000000) s(i);
VACUUM t;
CHECKPOINT;

SET default_statistics_target = 100;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 1000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 5000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 10000;

ANALYZE t;
ANALYZE t;
ANALYZE t;



TRUNCATE t;

INSERT INTO t SELECT 1000*random(), 1000*random() FROM generate_series(1,3000000) s(i);
VACUUM t;
CHECKPOINT;

SET default_statistics_target = 100;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 1000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 5000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 10000;

ANALYZE t;
ANALYZE t;
ANALYZE t;






DROP TABLE t;

CREATE TABLE t (a text, b text);
CREATE STATISTICS s (mcv) ON a, b FROM t;

TRUNCATE t;

INSERT INTO t SELECT md5((10*random())::int::text), md5((10*random())::int::text) FROM generate_series(1,3000000) s(i);
VACUUM t;
CHECKPOINT;

SET default_statistics_target = 100;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 1000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 5000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 10000;

ANALYZE t;
ANALYZE t;
ANALYZE t;


TRUNCATE t;

INSERT INTO t SELECT md5((100*random())::int::text), md5((100*random())::int::text) FROM generate_series(1,3000000) s(i);
VACUUM t;
CHECKPOINT;

SET default_statistics_target = 100;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 1000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 5000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 10000;

ANALYZE t;
ANALYZE t;
ANALYZE t;



TRUNCATE t;

INSERT INTO t SELECT md5((1000*random())::int::text), md5((1000*random())::int::text) FROM generate_series(1,3000000) s(i);
VACUUM t;
CHECKPOINT;

SET default_statistics_target = 100;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 1000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 5000;

ANALYZE t;
ANALYZE t;
ANALYZE t;

SET default_statistics_target = 10000;

ANALYZE t;
ANALYZE t;
ANALYZE t;
