第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

程序未使用 MongoDB 擴(kuò)展

程序未使用 MongoDB 擴(kuò)展

C#
明月笑刀無情 2021-10-24 20:36:46
我有一個(gè)代碼可以按名稱在 MongoDB 中搜索人員。我的代碼的問題是它沒有擴(kuò)展,我試圖用 40 個(gè)線程運(yùn)行這段代碼,但是當(dāng)我在我的數(shù)據(jù)庫中看到反應(yīng)時(shí),我不得不關(guān)閉它,因?yàn)樗加昧?100% 的 CPU。正在搜索的所有三個(gè)字段都在 MongoDB 中建立索引。有沒有辦法改進(jìn)查詢?我需要運(yùn)行 500 萬個(gè)名字,而我的數(shù)據(jù)庫有超過 2 億人。public Person searchPerson(string name){    string MongoUser = "MONGO_USERNAME";    string MongoPass = "MONGO_PASSWORD";    string MongoURL  = "MONGO_URL";    string MongoDB   = "MONGO_DB";     MongoClient _client = new MongoClient("mongodb://" + MongoUser + ":" + MongoPass + "@" + MongoURL);    IMongoCollection<BazingaPerson> myCollection   = _client.GetDatabase (MongoDB).GetCollection<Person>         ("COLLECTION_NAME");    List<Person> peopleList = myCollection.AsQueryable<Person>().Where(e => e.Name == name).ToList<Person>();    // both functions below only transform string like replace, substring or splits . They dont query in a DB or make web requests    string nameInitials = getInitials(name);     string phoneticName = getPhoneticName(name);    if(peopleList.Count() == 0) peopleList = myCollection.AsQueryable<Person>().Where(e => e.StandardName.Equals (phoneticName)).ToList<Person>();    if(peopleList.Count() == 0) peopleList = myCollection.AsQueryable<Person>().Where(e => e.Initials.Equals (nameInitials)).ToList<Person>();    if(peopleList.Count() == 0) return null;    return peopleList[0];}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 181 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)