Skip to content

Commit

Permalink
Merge #53831
Browse files Browse the repository at this point in the history
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
craig[bot] and yuzefovich committed Sep 19, 2020
2 parents 714ffe2 + 2093328 commit d6f9163
Show file tree
Hide file tree
Showing 2 changed files with 435 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/ccl/workloadccl/allccl/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
_ "github.com/cockroachdb/cockroach/pkg/workload/examples"
_ "github.com/cockroachdb/cockroach/pkg/workload/geospatial"
_ "github.com/cockroachdb/cockroach/pkg/workload/indexes"
_ "github.com/cockroachdb/cockroach/pkg/workload/interleavebench"
_ "github.com/cockroachdb/cockroach/pkg/workload/interleavedpartitioned"
_ "github.com/cockroachdb/cockroach/pkg/workload/jsonload"
_ "github.com/cockroachdb/cockroach/pkg/workload/kv"
Expand Down
Loading

0 comments on commit d6f9163

Please sign in to comment.