diff --git a/cmd/chai/commands/bench.go b/cmd/chai/commands/bench.go index 7eeabba0..5572dbda 100644 --- a/cmd/chai/commands/bench.go +++ b/cmd/chai/commands/bench.go @@ -40,7 +40,7 @@ $ chai bench -p mydb/ "SELECT 1" To prepare the database before running a query, use the -i/--init option -$ chai bench -p "CREATE TABLE foo; INSERT INTO foo(a) VALUES (1), (2), (3)" "SELECT * FROM foo" +$ chai bench -i "CREATE TABLE foo(a INT PRIMARY KEY); INSERT INTO foo(a) VALUES (1), (2), (3)" "SELECT * FROM foo" By default, each query is run in a separate transaction. To run everything, including the setup, in the same transaction, use -t`, diff --git a/cmd/chai/dbutil/bench.go b/cmd/chai/dbutil/bench.go index 4e427491..01600e4f 100644 --- a/cmd/chai/dbutil/bench.go +++ b/cmd/chai/dbutil/bench.go @@ -94,9 +94,9 @@ func Bench(ctx context.Context, db *sql.DB, query string, opt BenchOptions) erro err := enc(map[string]interface{}{ "totalQueries": i + opt.SampleSize, - "averageDuration": avg, + "averageDuration": avg.String(), "queriesPerSecond": qps, - "totalDuration": totalDuration, + "totalDuration": totalDuration.String(), }) if err != nil { return err diff --git a/internal/encoding/helpers.go b/internal/encoding/helpers.go index d8ef3cad..d1f9fbca 100644 --- a/internal/encoding/helpers.go +++ b/internal/encoding/helpers.go @@ -265,19 +265,6 @@ func compareNonEmptyValues(t byte, a, b []byte) (cmp int, n int) { panic(fmt.Sprintf("unsupported value type: %d", a[0])) } -func Successor(dst, a []byte) []byte { - if len(a) == 0 { - return a - } - - namespace, _ := DecodeInt(a) - if namespace == math.MaxInt64 { - return a - } - namespace++ - return EncodeInt(dst, namespace) -} - // AbbreviatedKey returns a shortened version that is used for // comparing keys during indexed batch comparisons. // The key is not guaranteed to be unique, but it respects the diff --git a/internal/kv/engine.go b/internal/kv/engine.go index 417a2a49..ac4b8055 100644 --- a/internal/kv/engine.go +++ b/internal/kv/engine.go @@ -114,11 +114,13 @@ var DefaultComparer = &pebble.Comparer{ } return encoding.Compare(a[an:], b[bn:]) }, - Equal: encoding.Equal, - AbbreviatedKey: encoding.AbbreviatedKey, - FormatKey: pebble.DefaultComparer.FormatKey, - Separator: encoding.Separator, - Successor: encoding.Successor, + Equal: encoding.Equal, + AbbreviatedKey: encoding.AbbreviatedKey, + FormatKey: pebble.DefaultComparer.FormatKey, + Separator: encoding.Separator, + Successor: func(dst, a []byte) []byte { + return a + }, Split: encoding.Split, ComparePointSuffixes: encoding.Compare, CompareRangeSuffixes: encoding.Compare,