Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/tsbs_load_timescaledb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ func initProgramOptions() (*timescaledb.LoadingOptions, load.BenchmarkRunner, *l
opts.ChunkTime = viper.GetDuration("chunk-time")

opts.UseColumnstore = viper.GetBool("use-columnstore")
opts.DirectCompress = viper.GetBool("columnstore-direct-compress")
opts.ColumnstoreSegmentBy = viper.GetString("columnstore-segmentby")
opts.ColumnstoreOrderBy = viper.GetString("columnstore-orderby")
opts.ColumnstoreSparseIdx = viper.GetString("columnstore-sparse-index")

opts.UseJSON = viper.GetBool("use-jsonb-tags")

Expand Down
62 changes: 43 additions & 19 deletions docs/timescaledb.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ in the connection string will be overridden with the values from the flags

Whether to actually use TimescaleDB's hypertable for storing data. Set to
`false` to measure the insert/write performance of plain PostgreSQL.
Hypertables are created with `CREATE TABLE ... WITH (tsdb.hypertable, ...)`,
which requires TimescaleDB 2.20 or later.

#### `-user` (type: `string`, default: `postgres`)

Expand Down Expand Up @@ -114,24 +116,49 @@ time.Duration string, meaning a number followed by a unit abbreviation
(s = seconds, m = minutes, h = hours), e.g., the default `12h` is 12 hours.
This should be adjusted based on the dataset size.

#### `-use-columnstore` (type: `boolean`, default: `false`)
Whether to convert every chunk to the columnstore (hypercore) once the load
has finished, and then run `ANALYZE`. Without this flag the data stays in
uncompressed rowstore chunks, which is not how TimescaleDB is normally
deployed, so storage size and query results will not reflect a typical
installation. Requires TimescaleDB 2.18 or later and `-use-hypertable`.

The conversion runs after the load has been timed, so it does not affect the
reported ingest rate.
#### `-use-columnstore` (type: `boolean`, default: `true`)
Whether to enable the columnstore (hypercore) on the hypertables, which is how
TimescaleDB is normally deployed. Set it to `false` to keep the data in
uncompressed rowstore chunks. It only applies to hypertables and is ignored
with `-use-hypertable=false`.

#### `-columnstore-direct-compress` (type: `boolean`, default: `true`)
Whether to load straight into the columnstore. The hypertables are created
with `tsdb.direct_compress`, so every `COPY` or `INSERT` writes compressed
batches and the compression is part of the timed load. Requires TimescaleDB
2.29 or later; on older versions set it to `false`.

With `false`, the loader writes uncompressed chunks and leaves them to the
columnstore policy that TimescaleDB creates, which converts them in the
background on its own schedule. Queries may then run against a mix of
compressed and uncompressed chunks.

Direct compress builds its batches from each insert batch, so a small
`-batch-size` spread over many hosts gives small compressed batches (for the
cpu-only use case at scale 200, the default batch size gives about 50 rows per
batch). A larger `-batch-size` gives fuller batches and better compression, at
some cost in ingest rate. The compaction policy TimescaleDB creates alongside
does not reliably merge them afterwards.

#### `-columnstore-segmentby` (type: `string`, default: `tags_id`)
The `timescaledb.segmentby` setting used with `-use-columnstore`. The default
The `tsdb.segmentby` setting used with `-use-columnstore`. The default
segments by the tag set, which suits queries that filter or group by host or
device. Set it to an empty string for no segmentby. If you load with
`-in-table-partition-tag`, consider segmenting by that column instead.
device. Set it to an empty string to leave the choice to TimescaleDB. If you
load with `-in-table-partition-tag`, consider segmenting by that column instead.

#### `-columnstore-orderby` (type: `string`, default: `time DESC`)
The `timescaledb.orderby` setting used with `-use-columnstore`.
The `tsdb.orderby` setting used with `-use-columnstore`.

#### `-columnstore-sparse-index` (type: `string`, default: empty)
The `tsdb.sparse_index` setting used with `-use-columnstore`, e.g.
`minmax(usage_user)`. Use `minmax` for range filters, `bloom` for equality
filters and `firstlast` for latest-value lookups; none is allowed on a
segmentby column, each column takes at most one, and the orderby column always
gets one implicitly. Leave it empty to let TimescaleDB choose.

For example, `firstlast` on every column lets the `lastpoint` query be
answered from batch metadata without decompressing anything, for about 20%
more storage.

#### `-partitions` (type: `int`, default: `0`)
Number of space partitions for the primary tag. Setting this to `0` will
Expand All @@ -143,12 +170,9 @@ distributed hypertable will be created across all connected data nodes, which
is the preferred setup.

#### `-replication-factor` (type: `int`, default: `0`)
This setting is specifically required to create a distributed hypertable. This
is only supported on multi-node installations. Setting it to a value of 1 is
recommended for most multi-node testing.

If this value is set >=1 on a single-node TimescaleDB instance, `tsbs_load` will
error.
This setting created a distributed hypertable on multi-node installations.
Multi-node was removed in TimescaleDB 2.14, so any value >= 1 now makes
`tsbs_load` fail before loading.

### Index related

Expand Down
1 change: 0 additions & 1 deletion load/loader-no-flow-control.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func (l *noFlowBenchmarkRunner) RunBenchmark(b targets.Benchmark) {
close(c)
}
l.postRun(wg, start)
l.postLoad(b)
}

// createChannels create channels from which workers would receive tasks
Expand Down
15 changes: 0 additions & 15 deletions load/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,6 @@ func (l *CommonBenchmarkRunner) RunBenchmark(b targets.Benchmark) {
}

l.postRun(wg, start)
l.postLoad(b)
}

// postLoad gives the DBCreator a chance to do work on the loaded data. It runs
// after postRun, so it is not part of the timed and reported load.
func (l *CommonBenchmarkRunner) postLoad(b targets.Benchmark) {
if !l.DoLoad {
return
}
if dbcpl, ok := b.GetDBCreator().(targets.DBCreatorPostLoad); ok {
if err := dbcpl.PostLoad(l.DBName); err != nil {
log.Println("could not execute PostLoad:" + err.Error())
panic(err)
}
}
}

// useDBCreator handles a DBCreator by running it according to flags set by the
Expand Down
55 changes: 0 additions & 55 deletions load/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,58 +479,3 @@ func TestReport(t *testing.T) {
t.Errorf("TestReport: row report ends in -")
}
}

type testCreatorPostLoad struct {
testCreator
postLoadCalled bool
errPostLoad bool
}

func (c *testCreatorPostLoad) PostLoad(string) error {
c.postLoadCalled = true
if c.errPostLoad {
return fmt.Errorf("post load error")
}
return nil
}

type testBenchmarkWithCreator struct {
testBenchmark
creator targets.DBCreator
}

func (b *testBenchmarkWithCreator) GetDBCreator() targets.DBCreator { return b.creator }

func TestPostLoad(t *testing.T) {
cases := []struct {
desc string
doLoad bool
errPostLoad bool
wantCalled bool
wantPanic bool
}{
{desc: "called after a load", doLoad: true, wantCalled: true},
{desc: "skipped when not loading", doLoad: false, wantCalled: false},
{desc: "error panics", doLoad: true, errPostLoad: true, wantCalled: true, wantPanic: true},
}
for _, c := range cases {
creator := &testCreatorPostLoad{errPostLoad: c.errPostLoad}
r := &CommonBenchmarkRunner{BenchmarkRunnerConfig: BenchmarkRunnerConfig{DoLoad: c.doLoad}}
didPanic := func() (p bool) {
defer func() { p = recover() != nil }()
r.postLoad(&testBenchmarkWithCreator{creator: creator})
return
}()
if creator.postLoadCalled != c.wantCalled {
t.Errorf("%s: PostLoad called = %v, want %v", c.desc, creator.postLoadCalled, c.wantCalled)
}
if didPanic != c.wantPanic {
t.Errorf("%s: panic = %v, want %v", c.desc, didPanic, c.wantPanic)
}
}

// a creator without PostLoad, and no creator at all, are both fine
r := &CommonBenchmarkRunner{BenchmarkRunnerConfig: BenchmarkRunnerConfig{DoLoad: true}}
r.postLoad(&testBenchmarkWithCreator{creator: &testCreator{}})
r.postLoad(&testBenchmark{})
}
10 changes: 0 additions & 10 deletions pkg/targets/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ type DBCreatorCloser interface {
Close()
}

// DBCreatorPostLoad is a DBCreator that also needs to do some work once all the
// data has been loaded (e.g., converting it to a different storage layout).
// It runs after the load has been timed and its results reported.
type DBCreatorPostLoad interface {
DBCreator

// PostLoad runs after the load has finished
PostLoad(dbName string) error
}

// DBCreatorPost is a DBCreator that also needs to do some initialization after the
// database is created (e.g., only one client should actually create the DB, so
// non-creator clients should still set themselves up for writing)
Expand Down
Loading
Loading