MongoDb -索引 + $type + 分析函數(shù) explain

索引:

db.testCo2.ensureIndex({"name":1}); //普通索引

db.testCo2.reIndex();當(dāng)前集合的所有index信息

db.testCo2.ensureIndex({“name”:1},{“unique”:true}); //唯一索引:

db.testCo2.getIndexes(); //查詢所有的索引

db.testCo2.dropIndex("name_1_age_1"); //刪除索引

//使用hint強(qiáng)制要求查詢操作使用某個(gè)索引

db.testCo2.find({name:"cgh",age:23}).hint({name:1}) //強(qiáng)制使用索引



分析函數(shù):

db.testCo2.find().explain();


$type 字段類(lèi)型搜索

db.testCo2.find({

"name":{

"$type":10

}});

{?

"_id" :ObjectId("5a03b44e73232118c78f3546"),?

"id" :"221",

"name" : null

}

Double 1

String 2

Object 3

Array 4

Binary data 5

Object id 7

Boolean 8

Date 9

Null 10

Regular expression 11

JavaScript code 13

Symbol 14

JavaScript code with scope 15

32-bit integer 16

Timestamp 17

64-bit integer 18

Min key 255

Max key 127

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容