Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53831: workload: add interleavebench workload r=yuzefovich a=yuzefovich This commit adds `interleavebench` workload that can be used to benchmark DELETE queries for interleaved and non-interleaved tables. It supports different number of levels (minimum 2), custom ratio in number of rows between levels, and several other parameters. As an example, for the following initialization ``` ./bin/workload init interleavebench --drop --interleave=false --levels=3 --hierarchy=1,3,2 --ratio=10 --intra-level-ratio=0.5 ``` these queries will be executed: ``` CREATE TABLE table0_0 (c0 INT, PRIMARY KEY (c0)); CREATE TABLE table1_0 (c0 INT, c1 INT, PRIMARY KEY (c0, c1)); CREATE TABLE table1_1 (c0 INT, c1 INT, PRIMARY KEY (c0, c1)); CREATE TABLE table1_2 (c0 INT, c1 INT, PRIMARY KEY (c0, c1)); CREATE TABLE table2_0 (c0 INT, c1 INT, c2 INT, PRIMARY KEY (c0, c1, c2)); CREATE TABLE table2_1 (c0 INT, c1 INT, c2 INT, PRIMARY KEY (c0, c1, c2)); ALTER TABLE table1_0 ADD CONSTRAINT fk FOREIGN KEY (c0) REFERENCES table0_0(c0) ON DELETE CASCADE; ALTER TABLE table1_1 ADD CONSTRAINT fk FOREIGN KEY (c0) REFERENCES table0_0(c0) ON DELETE CASCADE; ALTER TABLE table1_2 ADD CONSTRAINT fk FOREIGN KEY (c0) REFERENCES table0_0(c0) ON DELETE CASCADE; ALTER TABLE table2_0 ADD CONSTRAINT fk FOREIGN KEY (c0, c1) REFERENCES table1_0(c0, c1) ON DELETE CASCADE; ALTER TABLE table2_1 ADD CONSTRAINT fk FOREIGN KEY (c0, c1) REFERENCES table1_0(c0, c1) ON DELETE CASCADE; INSERT INTO table0_0 (SELECT i FROM generate_series(1, 100) AS i); INSERT INTO table1_0 (SELECT floor((i-1)*0.10)::INT+1, i FROM generate_series(1, 1000) AS i); INSERT INTO table1_1 (SELECT floor((i-1)*0.20)::INT+1, i FROM generate_series(1, 500) AS i); INSERT INTO table1_2 (SELECT floor((i-1)*0.40)::INT+1, i FROM generate_series(1, 250) AS i); INSERT INTO table2_0 (SELECT floor((i-1)*0.01)::INT+1, floor((i-1)*0.10)::INT+1, i FROM generate_series(1, 10000) AS i); INSERT INTO table2_1 (SELECT floor((i-1)*0.02)::INT+1, floor((i-1)*0.20)::INT+1, i FROM generate_series(1, 5000) AS i); ``` Then, during `run` the workload can execute DELETE queries like: ``` DELETE FROM table0 WHERE c0 IN ($1, $2, ...); ``` or ``` DELETE FROM table0 WHERE c0 >= $1 AND c0 < $1 + 1; ``` The table from which to delete as well as the number of rows to be deleted by one query can be customized. The workload does keep track of which rows are deleted in order to issue non-overlapping deletes. That is why it ignores `concurrency` flag and always runs with no concurrency. Fixes: #53455. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
- Loading branch information