当您使用 explain 方法运行MongoDB Vector Search查询时,该查询会返回一个 BSON文档,其中包含查询计划和描述查询在内部运行方式的执行统计信息。
语法
db.<myCollection>.explain("<verbosity>").aggregate([ { "$vectorSearch": { "exact": true | false, "filter": {<filter-specification>}, "index": "<index-name>", "limit": <number-of-results>, "numCandidates": <number-of-candidates>, "path": "<field-to-search>", "queryVector": [<array-of-numbers>], "explainOptions": { "traceDocumentIds": [<array-of-document-IDs>] } } } ])
详细程度
详细模式控制 explain 的行为和返回的信息量。值可以是以下之一,按详细程度降序排列:
有关查询计划的信息,包括 | |
有关查询计划的信息,包括 | |
queryPlanner(默认) | 有关查询计划的信息。不包括 |
解释结果
explain 方法返回包含以下字段的BSON文档。
选项 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| 文档 | Optional | 描述收集器的执行统计信息。 |
| 文档 | Optional | 包含有用的元数据。 |
| 文档 | Optional | 描述查询的执行统计信息。它不存在于 |
| 文档 | Optional | 有关在查询执行后检索每个文档数据的详细信息。 |
| 文档 | Optional | 详细说明执行查询时的资源使用情况。对于 |
| 对象数组 | Optional | |
| 对象数组 | Optional | 查询执行的每个 Lucene |
collectors
collectors 是包含以下字段的BSON文档:
字段 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| 文档 | 必需 | 查询的所有收集器的统计信息。报告的统计信息表示查询中使用的所有收集器的最大值或所有子收集器的统计信息总和。计时统计信息相加求和,以反映整个查询中所有收集器所花费的总时间。要学习;了解详情,请参阅 |
allCollectorStats
allCollectorStats 是一个BSON文档,描述查询中指定的所有收集器的收集器统计信息。它包含以下键:
字段 | 说明 |
|---|---|
| 追踪收集器收集的结果数量和持续时间。 |
| 统计信息跟踪从收集器请求 |
| 统计信息跟踪在收集器上设置记分器的总持续时间和次数。 |
metadata
metadata 包含有用的元数据,例如:
字段 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| 字符串 | Optional |
|
| 字符串 | Optional | 用于标识 |
| 字符串 | Optional | 查询中使用的MongoDB Vector Search索引。 |
| 文档 | Optional | 为 |
| 整型 | Optional | 索引中的文档总数(包括已删除的文档)。 |
query
explain 响应是一个 BSON 文档,其中的键和值描述了查询的执行统计数据。结果集中的 explain 文档包含以下字段:
字段 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| 字符串 | Optional | 所查询的 embedding 字段的路径(前提是它不是根)。 |
| 字符串 | 必需 | 向量搜索查询类型的名称。有关更多信息,请参阅 |
| 文档 | 必需 | 向量搜索查询信息。有关更多信息,请参阅 |
| 文档 | Optional |
args
解释响应包含如何在内部执行查询的信息。args字段包括以下详细信息:
查询类型
每种查询类型的结构化摘要示例
结构化摘要中的查询选项
以下部分描述了查询类型和结构化摘要中的字段:
WrappedKnnQuery用于组合多个查询的ANN向量搜索的包装器查询。结构化摘要包含有关以下选项的详细信息:
字段类型必要性说明query阵列
必需
向量搜索中使用的子查询数组,通常包含
KnnFloatVectorQuery和DocAndScoreQuery。
KnnFloatVectorQuery特定于浮点向量上的ANN搜索的查询类型。结构化摘要包含有关以下选项的详细信息:
字段类型必要性说明field字符串
必需
正在搜索的向量字段路径(Field Path)。
k整型
必需
要检索的最近邻数量。
ExactVectorSearchQuery用于新奥向量搜索的查询类型。结构化摘要包含有关以下选项的详细信息:
字段类型必要性说明field字符串
必需
正在搜索的向量字段路径(Field Path)。
similarityFunction字符串
必需
使用的相似度函数(
dotProduct、cosine或euclidean)。filter文档
Optional
用于限制向量搜索范围的预过滤查询。
BooleanQuery如果您在向量搜索查询中使用预过滤器,则您的解释结果将包含
BooleanQuery类型。要进一步学习;了解此类型的字段以及特定于预筛选查询的其他查询类型,请参阅MongoDB搜索解释页面上的查询类型。
stats
executionStats 和 allPlansExecution 详细模式的explain 响应包含一个stats 字段,该字段包含有关查询在 查询执行的各个阶段所 花费的 时间 的信息。
时序细分
时间细分描述了与查询执行区域相关的执行统计信息。以下字段显示时间细分:
查询区域
统计信息可用于以下查询领域:
resourceUsage
resourceUsage 文档显示了用于运行查询的资源。它包含以下字段:
字段 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| Long | 必需 | 主要页面错误的数量,当系统在查询执行期间无法在内存中找到所需数据,导致从磁盘等后备存储中读取数据时,就会发生这种错误。 |
| Long | 必需 | 次要页面错误的数量,当数据在页面缓存中,但尚未映射到进程的页表时发生。 |
| Long | 必需 | 在用户空间中花费的 CPU 时间,以毫秒为单位。 |
| Long | 必需 | 在系统空间中花费的 CPU 时间,以毫秒为单位。 |
| 整型 | 必需 | 在所有批处理中执行查询期间, |
| 整型 | 必需 | 处理查询时请求 |
vectorTracing
vectorTracing大量包含对象列表,每个文档一个对象,其中包含有关文档中向量的以下详细信息:
字段 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| 布尔 | 必需 | 指定在查询执行期间是否访问过跟踪向量的标志。 |
| 字符串 | 可选的 | 删除向量的原因。仅当访问了向量并将其从结果中删除时,才会出现此问题。值可以是:
|
| double | 可选的 | 与向量关联的分数。仅当向量被访问时才会出现 |
| 整型 | 必需 | 向量所属的Lucene段号。要学习;了解详情,请参阅 |
| 布尔 | 可选的 | 指定向量是否无法访问的标志。仅当向量无法访问时才会出现此问题。 |
luceneVectorSegmentStats
luceneVectorSegmentStats对象大量包含$vectorSearch 查询执行的每个 Lucene 段的细分。每个分段都由一个数字标识,并包含描述查询执行详细信息的参数。
{ "0": { "executionType": "Approximate", "approximateTimeMillis": 0.10825, "filterMatchedDocsCount": 0, "docCount": 100 }, "1": { "executionType": "Exact", "exactTimeMillis": 0.10825, "filterMatchedDocsCount": 0, "docCount": 55 }, "2": { "executionType": "ApproximateToExactFallback", "approximateTimeMillis": 0.10825, "exactTimeMillis": 0.10825, "filterMatchedDocsCount": 0, "docCount": 55 } }
字段 | 类型 | 必要性 | 用途 |
|---|---|---|---|
| 字符串 | 必需 | 执行策略。值可以是以下之一:
|
| Float | 可选的 | 近似阶段的时间(以毫秒为单位)。仅针对 |
| Float | 可选的 | Exact 阶段的时间(以毫秒为单位)。仅针对 |
| 整型 | Optional | 如果您在查询中指定了前置筛选器,则为与查询过滤匹配的文档数。 |
| 整型 | 必需 | 该分段中的文档总数。 |
示例
以下示例对示例ANN 和 ENN 查询使用 explain 方法。如果要在自己的环境中运行以下示例,则必须首先完成MongoDB Vector Search 快速入门,使用mongosh。
allPlansExecution
以下示例对plot_embedding_voyage_3_large 字段的 ANN 和 ENN向量搜索查询运行所述解释方法,详细程度模式为allPlansExecution 。
db.embedded_movies.explain("allPlansExecution").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "numCandidates": 150, "limit": 10 } } ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$vectorSearch': { 6 index: 'vector_index', 7 path: 'plot_embedding_voyage_3_large', 8 queryVector: 'redacted', 9 numCandidates: 150, 10 limit: 10, 11 explain: { 12 query: { 13 type: 'WrappedKnnQuery', 14 args: { 15 query: [ 16 { 17 type: 'InstrumentableKnnFloatVectorQuery', 18 args: { 19 field: '$type:knnVector/plot_embedding_voyage_3_large', 20 k: 150 21 }, 22 stats: { 23 context: { millisElapsed: 0 }, 24 match: { millisElapsed: 0 }, 25 score: { millisElapsed: 0 } 26 } 27 }, 28 { 29 type: 'DocAndScoreQuery', 30 args: {}, 31 stats: { 32 context: { 33 millisElapsed: 1.378949, 34 invocationCounts: { 35 createWeight: Long('1'), 36 createScorer: Long('4') 37 } 38 }, 39 match: { 40 millisElapsed: 0.341389, 41 invocationCounts: { nextDoc: Long('152') } 42 }, 43 score: { 44 millisElapsed: 0.205415, 45 invocationCounts: { 46 score: Long('150'), 47 setMinCompetitiveScore: Long('26') 48 } 49 } 50 } 51 } 52 ] 53 }, 54 stats: { 55 context: { 56 millisElapsed: 57.285674, 57 invocationCounts: { 58 vectorExecution: Long('1'), 59 createWeight: Long('1'), 60 createScorer: Long('4') 61 } 62 }, 63 match: { 64 millisElapsed: 0.341389, 65 invocationCounts: { nextDoc: Long('152') } 66 }, 67 score: { 68 millisElapsed: 0.205415, 69 invocationCounts: { 70 score: Long('150'), 71 setMinCompetitiveScore: Long('26') 72 } 73 } 74 } 75 }, 76 collectors: { 77 allCollectorStats: { 78 millisElapsed: 0.840381, 79 invocationCounts: { 80 collect: Long('150'), 81 competitiveIterator: Long('2'), 82 setScorer: Long('2') 83 } 84 } 85 }, 86 metadata: { 87 mongotVersion: '1.54.0', 88 mongotHostName: '<hostname>.mongodb.net', 89 indexName: 'vector_index', 90 lucene: { totalSegments: 2, totalDocs: 3483 } 91 }, 92 resourceUsage: { 93 majorFaults: Long('0'), 94 minorFaults: Long('0'), 95 userTimeMs: Long('0'), 96 systemTimeMs: Long('0'), 97 maxReportingThreads: 1, 98 numBatches: 1 99 }, 100 luceneVectorSegmentStats: [ 101 { 102 id: '_0', 103 executionType: 'Approximate', 104 docCount: 1952, 105 approximateStage: { millisElapsed: 32.916505 } 106 }, 107 { 108 id: '_1', 109 executionType: 'Approximate', 110 docCount: 1531, 111 approximateStage: { millisElapsed: 8.661519 } 112 } 113 ] 114 } 115 }, 116 nReturned: Long('10'), 117 executionTimeMillisEstimate: Long('256') 118 }, 119 { 120 '$_internalSearchIdLookup': { 121 limit: Long('10'), 122 subPipeline: [ 123 { '$match': { _id: { '$eq': '_id placeholder' } } } 124 ], 125 totalDocsExamined: Long('10'), 126 totalKeysExamined: Long('10'), 127 numDocsFilteredByIdLookup: Long('0') 128 }, 129 nReturned: Long('10'), 130 executionTimeMillisEstimate: Long('256') 131 } 132 ], 133 queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', 134 serverInfo: { 135 host: '<hostname>.mongodb.net', 136 port: 27017, 137 version: '8.2.1-rc1', 138 gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' 139 }, 140 serverParameters: { 141 internalQueryFacetBufferSizeBytes: 104857600, 142 internalQueryFacetMaxOutputDocSizeBytes: 104857600, 143 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, 144 internalDocumentSourceGroupMaxMemoryBytes: 104857600, 145 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, 146 internalQueryProhibitBlockingMergeOnMongoS: 0, 147 internalQueryMaxAddToSetBytes: 104857600, 148 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, 149 internalQueryFrameworkControl: 'trySbeRestricted', 150 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 151 }, 152 command: { 153 aggregate: 'embedded_movies', 154 pipeline: [ 155 { 156 '$vectorSearch': { 157 index: 'vector_index', 158 path: 'plot_embedding_voyage_3_large', 159 queryVector: [ 160 -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, 161 ..., 162 -0.006688767, 0.047527634, 0.040714234 163 ], 164 numCandidates: 150, 165 limit: 10 166 } 167 } 168 ], 169 cursor: {}, 170 '$db': 'sample_mflix' 171 }, 172 ok: 1, 173 '$clusterTime': { 174 clusterTime: Timestamp({ t: 1759341228, i: 32 }), 175 signature: { 176 hash: Binary.createFromBase64('BsaUr/khHU1Fyl5/g8htqoavlU8=', 0), 177 keyId: Long('7553982574624768005') 178 } 179 }, 180 operationTime: Timestamp({ t: 1759341228, i: 32 }) 181 }
db.embedded_movies.explain("allPlansExecution").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "exact": true, "limit": 10 } } ])
{ explainVersion: '1', stages: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: 'redacted', exact: true, limit: 10, explain: { query: { type: 'ExactVectorSearchQuery', args: { field: '$type:knnVector/plot_embedding_voyage_3_large', similarityFunction: 'dotProduct', filter: { type: 'DefaultQuery', args: { queryType: 'FieldExistsQuery' }, stats: { context: { millisElapsed: 0.756254, invocationCounts: { createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 3.835071, invocationCounts: { nextDoc: Long('3405') } }, score: { millisElapsed: 0 } } } }, stats: { context: { millisElapsed: 1.271846, invocationCounts: { createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 7.699638, invocationCounts: { nextDoc: Long('3405') } }, score: { millisElapsed: 139.077653, invocationCounts: { score: Long('3403'), setMinCompetitiveScore: Long('63') } } } }, collectors: { allCollectorStats: { millisElapsed: 146.798572, invocationCounts: { collect: Long('3403'), competitiveIterator: Long('2'), setScorer: Long('2') } } }, metadata: { mongotVersion: '1.54.0', mongotHostName: '<hostname>.mongodb.net', indexName: 'vector_index', lucene: { totalSegments: 2, totalDocs: 3483 } }, resourceUsage: { majorFaults: Long('0'), minorFaults: Long('0'), userTimeMs: Long('0'), systemTimeMs: Long('0'), maxReportingThreads: 1, numBatches: 1 } } }, nReturned: Long('10'), executionTimeMillisEstimate: Long('208') }, { '$_internalSearchIdLookup': { limit: Long('10'), subPipeline: [ { '$match': { _id: { '$eq': '_id placeholder' } } } ], totalDocsExamined: Long('10'), totalKeysExamined: Long('10'), numDocsFilteredByIdLookup: Long('0') }, nReturned: Long('10'), executionTimeMillisEstimate: Long('208') } ], queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', serverInfo: { host: '<hostname>.mongodb.net', port: 27017, version: '8.2.1-rc1', gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' }, serverParameters: { internalQueryFacetBufferSizeBytes: 104857600, internalQueryFacetMaxOutputDocSizeBytes: 104857600, internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, internalDocumentSourceGroupMaxMemoryBytes: 104857600, internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, internalQueryProhibitBlockingMergeOnMongoS: 0, internalQueryMaxAddToSetBytes: 104857600, internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, internalQueryFrameworkControl: 'trySbeRestricted', internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 }, command: { aggregate: 'embedded_movies', pipeline: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: [ -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, ..., -0.006688767, 0.047527634, 0.040714234 ], exact: true, limit: 10 } } ], cursor: {}, '$db': 'sample_mflix' }, ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1759341655, i: 1 }), signature: { hash: Binary.createFromBase64('/pUN/IbVV/OKyakbZcIug8HRS8M=', 0), keyId: Long('7553982574624768005') } }, operationTime: Timestamp({ t: 1759341655, i: 1 }) }
queryPlanner
以下示例对plot_embedding_voyage_3_large 字段的 ANN 和 ENN向量搜索查询运行所述解释方法,详细程度模式为queryPlanner 。
db.embedded_movies.explain("queryPlanner").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "numCandidates": 150, "limit": 10 } } ])
{ explainVersion: '1', stages: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: 'redacted', numCandidates: 150, limit: 10, explain: { query: { type: 'WrappedKnnQuery', args: { query: [ { type: 'InstrumentableKnnFloatVectorQuery', args: { field: '$type:knnVector/plot_embedding_voyage_3_large', k: 150 } }, { type: 'DocAndScoreQuery', args: {} } ] } }, metadata: { mongotVersion: '1.54.0', mongotHostName: '<hostname>.mongodb.net', indexName: 'vector_index', lucene: { totalSegments: 2, totalDocs: 3483 } } } } }, { '$_internalSearchIdLookup': { limit: Long('10'), subPipeline: [ { '$match': { _id: { '$eq': '_id placeholder' } } } ] } } ], queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', serverInfo: { host: '<hostname>.mongodb.net', port: 27017, version: '8.2.1-rc1', gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' }, serverParameters: { internalQueryFacetBufferSizeBytes: 104857600, internalQueryFacetMaxOutputDocSizeBytes: 104857600, internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, internalDocumentSourceGroupMaxMemoryBytes: 104857600, internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, internalQueryProhibitBlockingMergeOnMongoS: 0, internalQueryMaxAddToSetBytes: 104857600, internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, internalQueryFrameworkControl: 'trySbeRestricted', internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 }, command: { aggregate: 'embedded_movies', pipeline: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: [ -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, ..., -0.006688767, 0.047527634, 0.040714234 ], numCandidates: 150, limit: 10 } } ], cursor: {}, '$db': 'sample_mflix' }, ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1759341765, i: 1 }), signature: { hash: Binary.createFromBase64('rPjwbtfbjVrbcvkkN0ct/b1UYa8=', 0), keyId: Long('7553982574624768005') } }, operationTime: Timestamp({ t: 1759341765, i: 1 }) }
db.embedded_movies.explain("queryPlanner").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "exact": true, "limit": 10 } } ])
{ explainVersion: '1', stages: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: 'redacted', exact: true, limit: 10, explain: { query: { type: 'ExactVectorSearchQuery', args: { field: '$type:knnVector/plot_embedding_voyage_3_large', similarityFunction: 'dotProduct', filter: { type: 'DefaultQuery', args: { queryType: 'FieldExistsQuery' } } } }, metadata: { mongotVersion: '1.54.0', mongotHostName: '<hostname>.mongodb.net', indexName: 'vector_index', lucene: { totalSegments: 2, totalDocs: 3483 } } } } }, { '$_internalSearchIdLookup': { limit: Long('10'), subPipeline: [ { '$match': { _id: { '$eq': '_id placeholder' } } } ] } } ], queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', serverInfo: { host: '<hostname>.mongodb.net', port: 27017, version: '8.2.1-rc1', gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' }, serverParameters: { internalQueryFacetBufferSizeBytes: 104857600, internalQueryFacetMaxOutputDocSizeBytes: 104857600, internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, internalDocumentSourceGroupMaxMemoryBytes: 104857600, internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, internalQueryProhibitBlockingMergeOnMongoS: 0, internalQueryMaxAddToSetBytes: 104857600, internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, internalQueryFrameworkControl: 'trySbeRestricted', internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 }, command: { aggregate: 'embedded_movies', pipeline: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: [ -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, ..., -0.006688767, 0.047527634, 0.040714234 ], exact: true, limit: 10 } } ], cursor: {}, '$db': 'sample_mflix' }, ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1759342075, i: 1 }), signature: { hash: Binary.createFromBase64('jQiwcAMEmfzFnVU/pyb29TnYu0w=', 0), keyId: Long('7553982574624768005') } }, operationTime: Timestamp({ t: 1759342075, i: 1 }) }
executionStats
以下示例对plot_embedding_voyage_3_large 字段的 ANN 和 ENN向量搜索查询运行所述解释方法,详细程度模式为executionStats 。
db.embedded_movies.explain("executionStats").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "numCandidates": 150, "limit": 10 } } ])
{ explainVersion: '1', stages: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: 'redacted', numCandidates: 150, limit: 10, explain: { query: { type: 'WrappedKnnQuery', args: { query: [ { type: 'InstrumentableKnnFloatVectorQuery', args: { field: '$type:knnVector/plot_embedding_voyage_3_large', k: 150 }, stats: { context: { millisElapsed: 0 }, match: { millisElapsed: 0 }, score: { millisElapsed: 0 } } }, { type: 'DocAndScoreQuery', args: {}, stats: { context: { millisElapsed: 0.013013, invocationCounts: { createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 0.459619, invocationCounts: { nextDoc: Long('152') } }, score: { millisElapsed: 0.179147, invocationCounts: { score: Long('150'), setMinCompetitiveScore: Long('26') } } } } ] }, stats: { context: { millisElapsed: 7.113224, invocationCounts: { vectorExecution: Long('1'), createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 0.459619, invocationCounts: { nextDoc: Long('152') } }, score: { millisElapsed: 0.179147, invocationCounts: { score: Long('150'), setMinCompetitiveScore: Long('26') } } } }, collectors: { allCollectorStats: { millisElapsed: 0.868815, invocationCounts: { collect: Long('150'), competitiveIterator: Long('2'), setScorer: Long('2') } } }, metadata: { mongotVersion: '1.54.0', mongotHostName: '<hostname>.mongodb.net', indexName: 'vector_index', lucene: { totalSegments: 2, totalDocs: 3483 } }, resourceUsage: { majorFaults: Long('0'), minorFaults: Long('0'), userTimeMs: Long('0'), systemTimeMs: Long('0'), maxReportingThreads: 1, numBatches: 1 }, luceneVectorSegmentStats: [ { id: '_1', executionType: 'Approximate', docCount: 1531, approximateStage: { millisElapsed: 2.58089 } }, { id: '_0', executionType: 'Approximate', docCount: 1952, approximateStage: { millisElapsed: 3.483542 } } ] } }, nReturned: Long('10'), executionTimeMillisEstimate: Long('29') }, { '$_internalSearchIdLookup': { limit: Long('10'), subPipeline: [ { '$match': { _id: { '$eq': '_id placeholder' } } } ], totalDocsExamined: Long('10'), totalKeysExamined: Long('10'), numDocsFilteredByIdLookup: Long('0') }, nReturned: Long('10'), executionTimeMillisEstimate: Long('30') } ], queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', serverInfo: { host: '<hostname>.mongodb.net', port: 27017, version: '8.2.1-rc1', gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' }, serverParameters: { internalQueryFacetBufferSizeBytes: 104857600, internalQueryFacetMaxOutputDocSizeBytes: 104857600, internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, internalDocumentSourceGroupMaxMemoryBytes: 104857600, internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, internalQueryProhibitBlockingMergeOnMongoS: 0, internalQueryMaxAddToSetBytes: 104857600, internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, internalQueryFrameworkControl: 'trySbeRestricted', internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 }, command: { aggregate: 'embedded_movies', pipeline: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: [ -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, ..., -0.006688767, 0.047527634, 0.040714234 ], numCandidates: 150, limit: 10 } } ], cursor: {}, '$db': 'sample_mflix' }, ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1759342175, i: 1 }), signature: { hash: Binary.createFromBase64('AZZrjVPfyyBofyQq/gzs9UBL+/Q=', 0), keyId: Long('7553982574624768005') } }, operationTime: Timestamp({ t: 1759342175, i: 1 }) }
db.embedded_movies.explain("executionStats").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "exact": true, "limit": 10 } } ])
{ explainVersion: '1', stages: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: 'redacted', exact: true, limit: 10, explain: { query: { type: 'ExactVectorSearchQuery', args: { field: '$type:knnVector/plot_embedding_voyage_3_large', similarityFunction: 'dotProduct', filter: { type: 'DefaultQuery', args: { queryType: 'FieldExistsQuery' }, stats: { context: { millisElapsed: 0.037129, invocationCounts: { createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 1.128957, invocationCounts: { nextDoc: Long('3405') } }, score: { millisElapsed: 0 } } } }, stats: { context: { millisElapsed: 0.061268, invocationCounts: { createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 2.531393, invocationCounts: { nextDoc: Long('3405') } }, score: { millisElapsed: 7.956341, invocationCounts: { score: Long('3403'), setMinCompetitiveScore: Long('63') } } } }, collectors: { allCollectorStats: { millisElapsed: 10.004281, invocationCounts: { collect: Long('3403'), competitiveIterator: Long('2'), setScorer: Long('2') } } }, metadata: { mongotVersion: '1.54.0', mongotHostName: '<hostname>.mongodb.net', indexName: 'vector_index', lucene: { totalSegments: 2, totalDocs: 3483 } }, resourceUsage: { majorFaults: Long('0'), minorFaults: Long('0'), userTimeMs: Long('0'), systemTimeMs: Long('0'), maxReportingThreads: 1, numBatches: 1 } } }, nReturned: Long('10'), executionTimeMillisEstimate: Long('25') }, { '$_internalSearchIdLookup': { limit: Long('10'), subPipeline: [ { '$match': { _id: { '$eq': '_id placeholder' } } } ], totalDocsExamined: Long('10'), totalKeysExamined: Long('10'), numDocsFilteredByIdLookup: Long('0') }, nReturned: Long('10'), executionTimeMillisEstimate: Long('26') } ], queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', serverInfo: { host: '<hostname>.mongodb.net', port: 27017, version: '8.2.1-rc1', gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' }, serverParameters: { internalQueryFacetBufferSizeBytes: 104857600, internalQueryFacetMaxOutputDocSizeBytes: 104857600, internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, internalDocumentSourceGroupMaxMemoryBytes: 104857600, internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, internalQueryProhibitBlockingMergeOnMongoS: 0, internalQueryMaxAddToSetBytes: 104857600, internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, internalQueryFrameworkControl: 'trySbeRestricted', internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 }, command: { aggregate: 'embedded_movies', pipeline: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: [ -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, ..., -0.006688767, 0.047527634, 0.040714234 ], exact: true, limit: 10 } } ], cursor: {}, '$db': 'sample_mflix' }, ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1759342255, i: 1 }), signature: { hash: Binary.createFromBase64('sHuAxj9o8MbGe4iRz0Pv1PSi+UY=', 0), keyId: Long('7553982574624768005') } }, operationTime: Timestamp({ t: 1759342255, i: 1 }) }
db.embedded_movies.explain("executionStats").aggregate([ { "$vectorSearch": { "index": "vector_index", "path": "plot_embedding_voyage_3_large", "queryVector": QUERY_EMBEDDING, "numCandidates": 150, "limit": 10, "explainOptions": { "traceDocumentIds": [ ObjectId('573a13d8f29313caabda6557'), ObjectId('573a1398f29313caabce98d9'), ObjectId('573a1391f29313caabcd8319'), ObjectId('573a1398f29313caabceb500'), ObjectId('573a1397f29313caabce780e') ] } } } ])
{ explainVersion: '1', stages: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: 'redacted', numCandidates: 150, limit: 10, explainOptions: { traceDocumentIds: [ ObjectId('573a13d8f29313caabda6557'), ObjectId('573a1398f29313caabce98d9'), ObjectId('573a1391f29313caabcd8319'), ObjectId('573a1398f29313caabceb500'), ObjectId('573a1397f29313caabce780e') ] }, explain: { query: { type: 'WrappedKnnQuery', args: { query: [ { type: 'InstrumentableKnnFloatVectorQuery', args: { field: '$type:knnVector/plot_embedding_voyage_3_large', k: 150 }, stats: { context: { millisElapsed: 0 }, match: { millisElapsed: 0 }, score: { millisElapsed: 0 } } }, { type: 'DocAndScoreQuery', args: {}, stats: { context: { millisElapsed: 0.010987, invocationCounts: { createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 0.009977, invocationCounts: { nextDoc: Long('152') } }, score: { millisElapsed: 0.018875, invocationCounts: { score: Long('150'), setMinCompetitiveScore: Long('26') } } } } ] }, stats: { context: { millisElapsed: 7.55246, invocationCounts: { vectorExecution: Long('1'), createWeight: Long('1'), createScorer: Long('4') } }, match: { millisElapsed: 0.009977, invocationCounts: { nextDoc: Long('152') } }, score: { millisElapsed: 0.018875, invocationCounts: { score: Long('150'), setMinCompetitiveScore: Long('26') } } } }, collectors: { allCollectorStats: { millisElapsed: 0.148807, invocationCounts: { collect: Long('150'), competitiveIterator: Long('2'), setScorer: Long('2') } } }, metadata: { mongotVersion: '1.54.0', mongotHostName: '<hostname>.mongodb.net', indexName: 'vector_index', lucene: { totalSegments: 2, totalDocs: 3483 } }, resourceUsage: { majorFaults: Long('0'), minorFaults: Long('0'), userTimeMs: Long('0'), systemTimeMs: Long('0'), maxReportingThreads: 1, numBatches: 1 }, vectorTracing: [ { documentId: ObjectId('573a1391f29313caabcd8319'), visited: false, luceneSegment: '_0' }, { documentId: ObjectId('573a1397f29313caabce780e'), visited: true, vectorSearchScore: 0.7469133734703064, luceneSegment: '_0' }, { documentId: ObjectId('573a1398f29313caabce98d9'), visited: false, luceneSegment: '_0' }, { documentId: ObjectId('573a1398f29313caabceb500'), visited: true, vectorSearchScore: 0.7521393895149231, luceneSegment: '_0' }, { documentId: ObjectId('573a13d8f29313caabda6557'), visited: true, vectorSearchScore: 0.7710106372833252, luceneSegment: '_1' } ], luceneVectorSegmentStats: [ { id: '_1', executionType: 'Approximate', docCount: 1531, approximateStage: { millisElapsed: 2.73042 } }, { id: '_0', executionType: 'Approximate', docCount: 1952, approximateStage: { millisElapsed: 4.136979 } } ] } }, nReturned: Long('10'), executionTimeMillisEstimate: Long('21') }, { '$_internalSearchIdLookup': { limit: Long('10'), subPipeline: [ { '$match': { _id: { '$eq': '_id placeholder' } } } ], totalDocsExamined: Long('10'), totalKeysExamined: Long('10'), numDocsFilteredByIdLookup: Long('0') }, nReturned: Long('10'), executionTimeMillisEstimate: Long('22') } ], queryShapeHash: '2E39BED257F2B59D3F8652E1A81A18B1140602C4E253DED9FE208D584EA00083', serverInfo: { host: '<hostname>.mongodb.net', port: 27017, version: '8.2.1-rc1', gitVersion: '3312bdcf28aa65f5930005e21c2cb130f648b8c3' }, serverParameters: { internalQueryFacetBufferSizeBytes: 104857600, internalQueryFacetMaxOutputDocSizeBytes: 104857600, internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, internalDocumentSourceGroupMaxMemoryBytes: 104857600, internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, internalQueryProhibitBlockingMergeOnMongoS: 0, internalQueryMaxAddToSetBytes: 104857600, internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, internalQueryFrameworkControl: 'trySbeRestricted', internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 }, command: { aggregate: 'embedded_movies', pipeline: [ { '$vectorSearch': { index: 'vector_index', path: 'plot_embedding_voyage_3_large', queryVector: [ -0.034731735, 0.008558298, -0.0153717, -0.029912498, 0.011549547, ..., -0.006688767, 0.047527634, 0.040714234 ], numCandidates: 150, limit: 10, explainOptions: { traceDocumentIds: [ ObjectId('573a13d8f29313caabda6557'), ObjectId('573a1398f29313caabce98d9'), ObjectId('573a1391f29313caabcd8319'), ObjectId('573a1398f29313caabceb500'), ObjectId('573a1397f29313caabce780e') ] } } } ], cursor: {}, '$db': 'sample_mflix' }, ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1759343038, i: 1 }), signature: { hash: Binary.createFromBase64('E3FSIwLHavtFVMsmuqJM5reQc4I=', 0), keyId: Long('7553982574624768005') } }, operationTime: Timestamp({ t: 1759343038, i: 1 }) }