From 44c0ef8ac76603399ad3509f66d0546b86c18a6a Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Sun, 3 Mar 2019 20:43:02 +0800 Subject: [PATCH] leveldb: skip resort for delete only level --- leveldb/version.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/leveldb/version.go b/leveldb/version.go index 63b86fe5..51361e5d 100644 --- a/leveldb/version.go +++ b/leveldb/version.go @@ -486,6 +486,12 @@ func (p *versionStaging) finish(trivial bool) *version { nt = append(nt, t) } + // Avoid resort if only files in this level are deleted + if len(scratch.added) == 0 { + nv.levels[level] = nt + continue + } + // For normal table compaction, one compaction will only involve two levels // of files. And the new files generated after merging the source level and // source+1 level related files can be inserted as a whole into source+1 level