DROP TABLE foo;

\set ntuples 1000000

CREATE UNLOGGED TABLE foo AS SELECT generate_series(1, :ntuples) i;

SELECT pg_stat_force_next_flush();
VACUUM foo;
SELECT pg_stat_force_next_flush();

SELECT n_live_tup, n_dead_tup, reltuples::int8 FROM pg_stat_user_tables pst JOIN pg_class pc ON (pc.oid = pst.relid) WHERE relid = 'foo'::regclass;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;

DELETE FROM foo WHERE i < (SELECT min(i) FROM foo) + (:ntuples * 0.01);
VACUUM foo;


SELECT n_live_tup, n_dead_tup, reltuples::int8 FROM pg_stat_user_tables pst JOIN pg_class pc ON (pc.oid = pst.relid) WHERE relid = 'foo'::regclass;

SELECT count(*) FROM foo;
