Created
August 4, 2016 15:00
-
-
Save kmoppel/3170590c9472baec1dbc4b361b93d1e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE pgbench_accounts | |
ADD created_on timestamptz, | |
DROP CONSTRAINT pgbench_accounts_pkey; | |
CREATE UNIQUE INDEX ON pgbench_accounts(aid, created_on DESC); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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