Last active
March 14, 2025 16:13
-
-
Save ololobus/973709aa333ec4f1bebe2facfbfab770 to your computer and use it in GitHub Desktop.
PostgreSQL pgbench schema
This file contains hidden or 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 aid random(1, 100000 * :scale) | |
\set bid random(1, 1 * :scale) | |
\set tid random(1, 10 * :scale) | |
\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; |
This file contains hidden or 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
CREATE TABLE pgbench_history ( | |
tid int, | |
bid int, | |
aid int, | |
delta int, | |
mtime timestamp, | |
filler char(22) | |
); | |
CREATE TABLE pgbench_tellers ( | |
tid int NOT NULL, | |
bid int, | |
tbalance int, | |
filler char(84) | |
) | |
WITH ( | |
fillfactor = 100 | |
); | |
CREATE TABLE pgbench_accounts ( | |
aid int NOT NULL, | |
bid int, | |
abalance int, | |
filler char(84) | |
) | |
WITH ( | |
fillfactor = 100 | |
); | |
CREATE TABLE pgbench_branches ( | |
bid int NOT NULL, | |
bbalance int, | |
filler char(88) | |
) | |
WITH ( | |
fillfactor = 100 | |
); | |
ALTER TABLE pgbench_branches | |
ADD PRIMARY KEY (bid); | |
ALTER TABLE pgbench_tellers | |
ADD PRIMARY KEY (tid); | |
ALTER TABLE pgbench_accounts | |
ADD PRIMARY KEY (aid); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment