[SERVER-1316] single object update, by _id, seems slow Created: 28/Jun/10  Updated: 12/Jul/16  Resolved: 19/Apr/11

Status: Closed
Project: Core Server
Component/s: Performance
Affects Version/s: None
Fix Version/s: 1.9.0

Type: Improvement Priority: Minor - P4
Reporter: Dwight Merriman Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-665 special case simple queries for speed... Closed
Participants:

 Description   

see test code below. 11 sec for multi update vs. 70sec from the shell on localhost. that seems like an awfully big difference to me. surely can be better for the iterative case?

-----------------------

x =

{ classname: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }

;

t = db.foo;
t.drop();

start = new Date();

for( var i = 0; i < 500000; i++ )
t.insert;
print( tojson( db.getLastError() ) );

print("insert done");
print(new Date() - start);
// e.g., 29secs

print(t.count());

start = new Date();

// multi update version
t.update(

{ classname: x.classname }

, { $set:

{ classname: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbb"}

}, false, true);
// e.g., 11sec

/* manual iteration version
t.find(

{'classname':x.classname}

).forEach(
function(u)
// faster:
//

{ u.classname="com.abcdefghijkl"; t.save(u); }


// e.g., 56secs

// slower:

{ u.classname="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbb"; t.save(u); }

// e.g., 70sec
);
*/
print( tojson( db.getLastError() ) );

print("modifications done");
print( new Date() - start );

print(t.count());



 Comments   
Comment by Dwight Merriman [ 31/Aug/11 ]

call db.getLastError() after the insert. this is not done
automatically. that's not the issue, i think, but will make the
results more meaningful.

the problem could be that the shell is slow – it can't keep up with
the database. if you did the test from C or C++ or Java i think you
would see a different result. if the db isn't maxing out one core,
that's the problem.

Comment by Eliot Horowitz (Inactive) [ 31/Aug/11 ]

Not sure what you mean - can you try 2.0.0-rc0, and if there are problems open a ticket with your issues.

Comment by free [ 31/Aug/11 ]

Could you please explain a bit how to resolve? or the where is the source code about this issue
Thanks

Comment by Eliot Horowitz (Inactive) [ 28/Jun/10 ]

I'm 90% sure its because of SERVER-665

Generated at Thu Feb 08 02:56:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.