MongoDB C# low performance issue -
i'm testing mongodb 1.6.5 speed , c# in win64 machine. use yahoo.geoplanet source load states, county, towns i'm not performant. have more 5 sec load states these source passing list web page in localhost. use id index. can suggest way perform. thanks
class bsonplaces { [bsonid] public string id { get; set; } public string iso { get; set; } public string name { get; set; } public string language { get; set; } public string place_type { get; set; } public string parent_id { get; set; } } public list<bsonplaces> get_states(string usecountry) { using (var helper = bsonhelper.create()) { var query = query.eq("place_type", "state"); if (!string.isnullorempty(usecountry)) query = query.and(query, query.eq("iso", usecountry)); var cursor = helper.geoplanet.placesrepository.db.places .findas<bsonplaces>(query); if (!string.isnullorempty(usecountry)) cursor.setsortorder(sortby.ascending("name")); return cursor.tolist(); } }
i suppose problem not in mongodb, loading can slow 2 reasons:
- you trying load big count of 'bsonplaces'(20000 example or more).
- some code on page take time.
for speed improvements can:
1.set limit items returned query:
cursor.setlimit(100); 2.create indexes 'name', 'iso', 'place_type':
helper.geoplanet.placesrepository.db.places.ensureindex("name");
Comments
Post a Comment