\set max_account 100000
\set num_trans (:max_account * 500)

DROP TABLE IF EXISTS accounts;
DROP TABLE IF EXISTS transactions;

CREATE TABLE accounts AS
  SELECT aid, random(1, 1000) bid
  FROM generate_series(1, :max_account ) aid;
CREATE INDEX ON accounts(aid);
CREATE INDEX ON accounts(bid);
CREATE TABLE transactions AS
  SELECT random(0, :max_account) as aid, random(-100000, 100000) as diff
  FROM (SELECT generate_series(1, :num_trans ));
CREATE INDEX ON transactions(aid);
ALTER TABLE transactions ADD COLUMN tid serial primary key;

VACUUM ANALYZE accounts, transactions;
