/*
drop table if exists stock100;
create table stock100
(
  s_i_id        integer
, s_w_id        smallint
, s_quantity    smallint
, s_order_cnt   smallint            -- not listed as a monetary value
, s_remote_cnt  smallint            -- not listed as a monetary value
, s_ytd         integer             -- not listed as a monetary value
, s_dist_01     char(24)
, s_dist_02     char(24)
, s_dist_03     char(24)
, s_dist_04     char(24)
, s_dist_05     char(24)
, s_dist_06     char(24)
, s_dist_07     char(24)
, s_dist_08     char(24)
, s_dist_09     char(24)
, s_dist_10     char(24)
, s_data        text                -- varchar(50)
);

-- drop table if exists testresult;
CREATE TABLE testresult (
  description text NOT NULL,
  begints timestamp DEFAULT (now()) NOT NULL,
  endts timestamp);

---

TRUNCATE stock100; CHECKPOINT;
INSERT INTO testresult (description) VALUES ('copy-head');
COPY stock100 FROM '/mnt/data/dbt2/test-w100/dbdata/stock.data';
UPDATE testresult SET endts = now() WHERE endts IS NULL;

---

TRUNCATE stock100; CHECKPOINT;
INSERT INTO testresult (description) VALUES ('copy-head');
COPY stock100 FROM '/mnt/data/dbt2/test-w100/dbdata/stock.data';
UPDATE testresult SET endts = now() WHERE endts IS NULL;


SELECT COUNT(*) FROM stock100; -- set hint bits

CHECKPOINT;
INSERT INTO testresult (description) VALUES ('select-head');
SELECT COUNT(*) FROM stock100;
UPDATE testresult SET endts = now() WHERE endts IS NULL;

CHECKPOINT;
INSERT INTO testresult (description) VALUES ('select-head');
SELECT COUNT(*) FROM stock100;
UPDATE testresult SET endts = now() WHERE endts IS NULL;

------- VACUUM tests -------

CHECKPOINT;
INSERT INTO testresult (description) VALUES ('vacuum-head');
VACUUM stock100;
UPDATE testresult SET endts = now() WHERE endts IS NULL;


CHECKPOINT;
INSERT INTO testresult (description) VALUES ('vacuum-head');
VACUUM stock100;
UPDATE testresult SET endts = now() WHERE endts IS NULL;

----

DROP TABLE IF EXISTS stock100_copy; 
SELECT * INTO stock100_copy FROM stock100;
DELETE FROM stock100_copy WHERE textin(tidout(ctid)) LIKE '%,1)' ;
CHECKPOINT;
INSERT INTO testresult (description) VALUES ('vacuum_dirty-head');
VACUUM VERBOSE stock100_copy;
UPDATE testresult SET endts = now() WHERE endts IS NULL;


DROP TABLE IF EXISTS stock100_copy; 
SELECT * INTO stock100_copy FROM stock100;
DELETE FROM stock100_copy WHERE textin(tidout(ctid)) LIKE '%,1)' ;
CHECKPOINT;
INSERT INTO testresult (description) VALUES ('vacuum_dirty-head');
VACUUM VERBOSE stock100_copy;
UPDATE testresult SET endts = now() WHERE endts IS NULL;
*/

DROP TABLE IF EXISTS stock100_copy; 
SELECT * INTO stock100_copy FROM stock100;

BEGIN; DELETE FROM stock100_copy WHERE textin(tidout(ctid)) LIKE '%,1)'; ROLLBACK;
CHECKPOINT;
INSERT INTO testresult (description) VALUES ('vacuum_hintbits-head');
VACUUM VERBOSE stock100_copy;
UPDATE testresult SET endts = now() WHERE endts IS NULL;


BEGIN; DELETE FROM stock100_copy WHERE textin(tidout(ctid)) LIKE '%,1)'; ROLLBACK;
CHECKPOINT;
INSERT INTO testresult (description) VALUES ('vacuum_hintbits-head');
VACUUM VERBOSE stock100_copy;
UPDATE testresult SET endts = now() WHERE endts IS NULL;


SELECT description, endts-begints FROM testresult;