索引后的Mongodb需要更长的执行时间



我有145359个文档存储在本地MongoDB中,我正在尝试对其进行索引。加快我的查询速度。

{
"Categorized": true
}

样本文件

{
"_id" : "dbe14c04-bd1e-454a-af57-4ca61566c0c0",
"Categorized" : true,
"Archived" : false,
"HasTorrent" : false,
"TorrentFile" : null,
"File" : {
"TitlePattern" : null,
"Extension" : ".mp4",
"FileName" : "A Costume for Nicholas (Un Disfraz para Nicolas) (2020) 1080p WEBRip.mp4",
"FileNameWithoutExtension" : "A Costume for Nicholas (Un Disfraz para Nicolas) (2020) 1080p WEBRip",
"AdapterName" : "CandyBD",
"AdapterNameLower" : "candybd",
"Type" : 1,
"SupportedISPs" : [ 
"dotinternet"
]
},
"IsSaved" : false,
"IsUpdated" : true,
"MovieId" : "tt8045396",
"Quality" : 16,
"UpdateComplete" : true,
"WatchCount" : 0,
"Is3D" : false,
"FileFoundDateTime" : ISODate("2022-01-03T02:12:03.236Z"),
"InformationDateTime" : ISODate("2022-01-03T02:12:11.553Z"),
"Dimension" : "1080p",
"IsDubbed" : false
}

问题是当尝试通过对集合进行索引时

{
"Categorized" : 1
}

根据指南针,在索引之前,返回的文件:94057,检查的文件:145359中的94057,很棒。但问题是在索引实际查询执行时间(ms(之前:95(大约(,CollScan执行时间平均为0-11毫秒。但在索引实际询问执行时间(毫秒(之后:124 Fetch大约为9毫秒,Ixscan大约为5毫秒。

这个值是什么意思?为什么我的查询在索引后执行的时间更长?

集合中有145359个文档。当T/F分布接近50/50时,布尔字段不是特别好的索引候选字段,在这种情况下,有94057个文档(65%(与true匹配。指数在这里真的不会对你有实质性的帮助。

最新更新