Mongo:文档中的字段数是否会影响查询性能?

时间:2017-01-13 01:58:44

标签: mysql mongodb spring-mvc

我有一个名为school的集合,其中的文档如下:

{
    "_id" : 0,
    "_class" : "com.aixueniao.server.model.School",
    "companyUserId" : 0,
    "schoolUserId" : 0,
    "schoolName" : "校区名称",
    "showSchoolName" : 0,
    "gradeIds" : "[]",
    "firstLevelSubjectIds" : "[]",
    "secondLevelSubjectIds" : "[]",
    "classType" : "",
    "introduction" : "校区介绍",
    "mainImageId" : 0,
    "imageIds" : "[]",
    "longitude" : 0.0,
    "latitude" : 0.0,
    "locationId" : 0,
    "address" : "校区地址",
    "runningTime" : 0.0,
    "teacherCount" : 0,
    "telephone" : "",
    "fixedPhone" : "",
    "createTime" : "2017-01-13 01:16:54",
    "expirationTime" : "2017-01-13 01:16:54",
    "schoolStatus" : "ARREARS",
    "authorizationStatus" : "NO",
    "rejectReason" : "无"
}

文档中大约有26个字段,字段数是否会影响查询性能?我将查询4个字段,并将使用$ near查询。提前谢谢。

1 个答案:

答案 0 :(得分:0)

简单的答案是肯定的,这就是为什么Mongo为我们提供了像projections这样的功能,以便通过不让数据库返回文档中的所有字段来实现更好的性能