MongoDB Query Timing difference from shell and Android mobile -


i'm using mongodb mobile application store data's. when connect mongo server thro robomongo , query explain("executionstats") says

{     "cursor" : "idcursor",     "n" : 1,     "nscannedobjects" : 1,     "nscanned" : 1,     "indexonly" : false,     "millis" : 0,     "indexbounds" : {         "_id" : [              [                  objectid("5592a10d634a61834f354f3b"),                  objectid("5592a10d634a61834f354f3b")             ]         ]     },     "server" : "h003744.mongolab.com:55690" } 

and millis 0. when put same query in android application without explain command takes 4 5 sec result though i'm using index in query.

what mistake i'm doing here.

edit :

java code

basicdbobject user = new basicdbobject(tripsconstants._id, new objectid(id)); basicdbobject show = new basicdbobject(tripsconstants._id, 0).append(tripsconstants.user_email, 1).append(tripsconstants.total_time, 1)                     .append(tripsconstants.trip_description, 1).append(tripsconstants.total_distance, 1).append(tripsconstants.trip_rates, 1)                     .append(tripsconstants.trip_comments, 1); basicdbobject obj = (basicdbobject) coll.findone(user, show); 

shell query

db.getcollection('trip_details').find({_id : objectid("5592a10d634a61834f354f3b")},{ "_id" : 0 , "user_email" : 1 , "total_time" : 1 , "trip_description" : 1 , "total_distance" : 1 , "trip_rates" : 1 , "trip_comments" : 1 , "start_point" : 1 , "end_point" : 1 , "pause_point" : 1 , "resume_point" : 1 , "waypoints" : 1 , "waypoint_notes" : 1 , "waypoint_images" : 1 , "geometry" : 1}) 

indexes in mongodb

{     "0" : {         "v" : 1,         "key" : {             "_id" : 1         },         "name" : "_id_",         "ns" : "new_model.trip_details"     },     "1" : {         "v" : 1,         "key" : {             "_fts" : "text",             "_ftsx" : 1         },         "name" : "trip_name_text_waypoint_notes.notes_text_trip_description_text_waypoints.waypoint_name_text",         "ns" : "new_model.trip_details",         "weights" : {             "trip_description" : 1,             "trip_name" : 1,             "waypoint_notes.notes" : 1,             "waypoints.waypoint_name" : 1         },         "default_language" : "english",         "language_override" : "language",         "textindexversion" : 2     },     "2" : {         "v" : 1,         "key" : {             "geometry" : "2dsphere"         },         "name" : "geometry_2dsphere",         "ns" : "new_model.trip_details",         "2dsphereindexversion" : 2     },     "3" : {         "v" : 1,         "key" : {             "user_email" : 1.0000000000000000         },         "name" : "user_email_1",         "ns" : "new_model.trip_details"     } } 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -