-
Notifications
You must be signed in to change notification settings - Fork 565
Open
Labels
enhancementtype enhancementtype enhancement
Description
Search before asking
- I had searched in the issues and found no similar issues.
Motivation
Summary
Hi! 👋 While exploring the codebase, I noticed the EXISTS
command uses sequential Get
operations, while other multi-key commands like MGET
and MDEL
use MultiGet
. I'm wondering if this is intentional or if there might be a performance optimization opportunity here.
Current Implementation
Currently, Database::existsInternal()
uses a sequential approach:
rocksdb::Status Database::existsInternal(engine::Context &ctx, const std::vector<std::string> &keys, int *ret) {
*ret = 0;
rocksdb::Status s;
std::string value;
for (const auto &key : keys) { // Sequential Get operations
s = storage_->Get(ctx, ctx.GetReadOptions(), metadata_cf_handle_, key, &value);
if (!s.ok() && !s.IsNotFound()) return s;
if (s.ok()) {
Metadata metadata(kRedisNone, false);
s = metadata.Decode(value);
if (!s.ok()) return s;
if (!metadata.Expired()) *ret += 1;
}
}
return rocksdb::Status::OK();
}
What I observed
Other multi-key commands use MultiGet
:
MDEL
andMGET
both usestorage_->MultiGet()
for batch operationsEXISTS
uses a loop with individualGet
calls
Questions
I'm curious about:
- Is there a specific reason
EXISTS
uses sequentialGet
instead ofMultiGet
? - Would a
MultiGet
-based performance optimization be welcome?
Potential benefits
A MultiGet
-based implementation could potentially provide:
- Better performance through batch operations (fewer RocksDB calls)
- Consistency with other multi-key commands (
MGET
,MDEL
, etc.)
Code location
src/storage/redis_db.cc
- Database::existsInternal()
(lines 624-639)
Solution
No response
Are you willing to submit a PR?
- I'm willing to submit a PR!
Metadata
Metadata
Assignees
Labels
enhancementtype enhancementtype enhancement