ALTER SYSTEM SET fsync TO 'off';
SELECT pg_reload_conf();

DROP TABLE copy_test_setup;

CREATE TABLE copy_test_setup (
    value int
) WITH (fillfactor=20, autovacuum_enabled=false);
--) WITH (fillfactor=30, autovacuum_enabled=false);

DO $$
BEGIN
RAISE NOTICE 'Dropping tables';
  FOR i IN 1..100 LOOP
    EXECUTE FORMAT(
      'DROP TABLE %I',
      'copy_test' || i
    );
  END LOOP;
END;
$$;

DO $$
BEGIN
RAISE NOTICE 'Creating tables and inserting one tuple';
  FOR i IN 1..100 LOOP
    EXECUTE FORMAT(
      'CREATE UNLOGGED TABLE %I (LIKE copy_test_setup) WITH (fillfactor=20, autovacuum_enabled=false)',
--      'CREATE UNLOGGED TABLE %I (LIKE copy_test_setup) WITH (fillfactor=30, autovacuum_enabled=false)',
      'copy_test' || i
    );
    EXECUTE FORMAT(
      'INSERT INTO %I VALUES (0)',
      'copy_test' || i
    );
  END LOOP;
END;
$$;