Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Range delete for collection drops to reduce write amplification.

Kishore Nallan510283e441ff
diff --git a/include/store.h b/include/store.h
index ccbb2bae..68b7f635 100644
--- a/include/store.h
+++ b/include/store.h
@@ -359,6 +359,11 @@ public:
return db->DeleteRange(rocksdb::WriteOptions(), db->DefaultColumnFamily(), begin_key, end_key);
}
+ rocksdb::Status compact_range(const rocksdb::Slice& begin_key, const rocksdb::Slice& end_key) {
+ std::shared_lock lock(mutex);
+ return db->CompactRange(rocksdb::CompactRangeOptions(), &begin_key, &end_key);
+ }
+
// Only for internal tests
rocksdb::DB* _get_db_unsafe() const {
return db;
diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp
index aadcbf31..28bd0f5a 100644
--- a/src/collection_manager.cpp
+++ b/src/collection_manager.cpp
@@ -465,6 +465,7 @@ Option<nlohmann::json> CollectionManager::drop_collection(const std::string& col
const std::string& del_end_prefix = std::to_string(collection->get_collection_id()) + "`";
store->delete_range(del_key_prefix, del_end_prefix);
store->flush();
+ store->compact_range(del_key_prefix, del_end_prefix);
// delete overrides
const std::string& del_override_prefix =