寫入100萬條記錄,建立索引,使用索引連續查詢 10萬次。
十載的北海街道網站建設經驗,針對設計、前端、開發、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網營銷推廣的優勢是能夠根據用戶設備顯示端的尺寸不同,自動調整北海街道建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優雅布局與設計,從而大程度地提升瀏覽體驗。創新互聯從事“北海街道網站設計”,“北海街道網站推廣”以來,每個客戶項目都認真落實執行。
- use admin;//連接資料庫
- db.auth("mongoAdmin","123456");//登錄
- use test;//連接測試庫
- db.test_collection.dropIndexes();
- db.test_collection.drop();
- print("insert begin: "+Date());//寫入開始時間
- people = ["Marc", "Bill", "George", "Eliot", "Matt", "Trey", "Tracy", "Greg", "Steve", "Kristina", "Katie", "Jeff"];
- for(var i=10; i<1000000; i++){
- name = people[Math.floor(Math.random()*people.length)];
- user_id = i;
- boolean = [true, false][Math.floor(Math.random()*2)];
- added_at = new Date();
- number = Math.floor(Math.random()*10001);
- db.test_collection1.save({"name":name, "user_id":user_id, "boolean": boolean, "added_at":added_at, "number":number });
- };
- print("insert End: "+Date());//寫入結束時間
- db.test_collection.ensureIndex({user_id:1});
- print("find begin: "+Date());//查詢開始時間
- var i=0;
- var tempResult=null;
- while(i<100000){
- i=i+1;
- tempResult=db.test_collection.findOne({"user_id":Math.floor(Math.random()*1000000)});
- };
- print("find end: " + Date());//查詢結束時間
- print("game over");//最后一行,保證上一行執行
參照《10分鐘配置MongoDB集群》 ,本人筆記本電腦(4G內存)上性能測試結果如下:
insert begin: Mon Dec 24 2012 15:06:26 GMT+0800
insert End: Mon Dec 24 2012 15:10:14 GMT+0800
find begin: Mon Dec 24 2012 15:10:14 GMT+0800
find end: Mon Dec 24 2012 15:10:37 GMT+0800
大概就是平均一秒鐘寫入400多條,創建索引速度極快,使用索引平均每秒查詢3500多條。寫性能慢不覺得奇怪,畢竟是一臺普通的筆記本電腦上配了一個集群呢。
當前文章:MongoDB性能測試代碼
網站路徑:http://vcdvsql.cn/article0/pejioo.html
成都網站建設公司_創新互聯,為您提供網站改版、網站維護、網站制作、云服務器、建站公司、營銷型網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯