diff --git a/CHANGELOG.md b/CHANGELOG.md index 71335f6992..9386f8bd62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bugfixes - [#6604](https://github.com/influxdata/influxdb/pull/6604): Remove old cluster code +- [#6618](https://github.com/influxdata/influxdb/pull/6618): Optimize shard loading ## v0.13.0 [2016-05-12] diff --git a/tsdb/engine/tsm1/engine.go b/tsdb/engine/tsm1/engine.go index 5aa4813dfd..ca5c534d74 100644 --- a/tsdb/engine/tsm1/engine.go +++ b/tsdb/engine/tsm1/engine.go @@ -379,6 +379,12 @@ func (e *Engine) readFileFromBackup(tr *tar.Reader, shardRelativePath string) er // database index and measurement fields func (e *Engine) addToIndexFromKey(shardID uint64, key string, fieldType influxql.DataType, index *tsdb.DatabaseIndex) error { seriesKey, field := seriesAndFieldFromCompositeKey(key) + // Have we already indexed this series? + ss := index.Series(seriesKey) + if ss != nil { + return nil + } + measurement := tsdb.MeasurementFromSeriesKey(seriesKey) m := index.CreateMeasurementIndexIfNotExists(measurement) @@ -1230,9 +1236,10 @@ func tsmFieldTypeToInfluxQLDataType(typ byte) (influxql.DataType, error) { } func seriesAndFieldFromCompositeKey(key string) (string, string) { - parts := strings.Split(key, keyFieldSeparator) - if len(parts) != 0 { - return parts[0], strings.Join(parts[1:], keyFieldSeparator) + sep := strings.Index(key, keyFieldSeparator) + if sep == -1 { + // No field??? + return key, "" } - return parts[0], parts[1] + return key[:sep], key[sep+len(keyFieldSeparator):] }