0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-29 16:47:28 +01:00

make simple find faster

This commit is contained in:
Aaron 2009-04-06 17:32:40 -04:00
parent 0875581b5e
commit 91c4607f76
3 changed files with 12 additions and 5 deletions

View File

@ -274,6 +274,8 @@ namespace mongo {
return prettyKey( endKey );
}
void forgetEndKey() { endKey = BSONObj(); }
private:
/* Our btrees may (rarely) have "unused" keys when items are deleted.
Skip past them.

View File

@ -82,9 +82,11 @@ namespace mongo {
void BtreeCursor::checkEnd() {
if ( bucket.isNull() )
return;
int cmp = sgn( endKey.woCompare( currKey(), order ) );
if ( cmp != 0 && cmp != direction )
bucket = DiskLoc();
if ( !endKey.isEmpty() ) {
int cmp = sgn( endKey.woCompare( currKey(), order ) );
if ( cmp != 0 && cmp != direction )
bucket = DiskLoc();
}
}
bool BtreeCursor::advance() {

View File

@ -857,10 +857,13 @@ namespace mongo {
query_ = spec_.getObjectField( "query" );
spec_.getObjectField( "fields" ).getFieldNames( fields_ );
c_ = qp().newCursor();
if ( qp().exactKeyMatch() && fields_.empty() )
if ( qp().exactKeyMatch() && fields_.empty() ) {
bc_ = dynamic_cast< BtreeCursor* >( c_.get() );
else
bc_->forgetEndKey();
}
else {
matcher_.reset( new JSMatcher( query_ ) );
}
}
virtual void next() {
if ( !c_->ok() ) {