Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ALTER TABLE pgbench_accounts
ADD created_on timestamptz,
DROP CONSTRAINT pgbench_accounts_pkey;
CREATE UNIQUE INDEX ON pgbench_accounts(aid, created_on DESC);
\set nbranches :scale
\set ntellers 10 * :scale
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\setrandom delta -5000 5000
BEGIN;
INSERT INTO pgbench_accounts (aid, abalance, created_on) SELECT :aid, abalance + :delta, now() FROM pgbench_accounts WHERE aid = :aid ORDER BY created_on DESC LIMIT 1;
SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
--INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.