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:
parent
0875581b5e
commit
91c4607f76
@ -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.
|
||||
|
@ -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() {
|
||||
|
@ -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() ) {
|
||||
|
Loading…
Reference in New Issue
Block a user