Skip to content

Instantly share code, notes, and snippets.

@erthalion
Created June 23, 2018 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erthalion/c85ba0e12146596d24c572234501e756 to your computer and use it in GitHub Desktop.
Save erthalion/c85ba0e12146596d24c572234501e756 to your computer and use it in GitHub Desktop.
\set aid random_zipfian(1, 100000 * :scale, 1.07)
\set bid random_zipfian(1, 1 * :scale, 1.07)
\set tid random_zipfian(1, 10 * :scale, 1.07)
\set delta random(-5000, 5000)
BEGIN;
UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
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