summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2015-01-22 10:48:35 -0500
committerDavid Storch <david.storch@10gen.com>2015-01-22 14:57:38 -0500
commit89ddf2d90625a7738b8e48dce1a5776942603d27 (patch)
treed51a60a3ef3e2aee69a2ad023289c6531e4a5f6e
parent816defcefba70ffe815639fa6bb157b69ef034ad (diff)
downloadmongo-89ddf2d90625a7738b8e48dce1a5776942603d27.tar.gz
SERVER-16982 WiredTiger index cursor pointsToSamePlaceAs() uses WT_CURSOR equals() function
This should improve WT index scan performance for scans qualifying for the fast-path added in SERVER-16437.
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
index be5cef4c8ce..b4ee396f6ae 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
@@ -584,15 +584,14 @@ namespace {
else if ( _eof || other._eof )
return false;
- // Check the locs first since they are likely to differ and comparing them is fast.
- if ( getRecordId() != other.getRecordId() )
+ // First try WT_CURSOR equals(), as this should be cheap.
+ int equal;
+ invariantWTOK(_cursor.get()->equals(_cursor.get(), other._cursor.get(), &equal));
+ if (!equal)
return false;
- loadKeyIfNeeded();
- other.loadKeyIfNeeded();
-
- return _key.getSize() == other._key.getSize()
- && memcmp(_key.getBuffer(), other._key.getBuffer(), _key.getSize()) == 0;
+ // WT says cursors are equal, but need to double-check that the RecordIds match.
+ return getRecordId() == other.getRecordId();
}
bool locate(const BSONObj &key, const RecordId& loc) {