explain メソッドを使用してMongoDB ベクトル検索クエリを実行すると、クエリはクエリプランとクエリが内部で実行された方法を説明する実行統計を含む BSON ドキュメントを返します。
Tip
構文
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 (デフォルト) | クエリプランに関する情報。 |
Tip
explain の結果
explain メソッドは、次のフィールドを含むBSONドキュメントを返します。
オプション | タイプ | 必要性 | 目的 |
|---|---|---|---|
| ドキュメント | 任意 | コレクターの実行統計を説明します。 |
| ドキュメント | 任意 | 有用なメタデータを含んでいます。 |
| ドキュメント | 任意 | クエリの実行統計を記述します。これは |
| ドキュメント | 任意 | クエリ実行後にドキュメントごとのデータを取得する方法の詳細。これは、 |
| ドキュメント | 任意 | クエリが実行されたときのリソース使用状況を詳述します。 |
| オブジェクトの配列 | 任意 | 指定されたドキュメント内のベクトルについて、次のような詳細をトレースします。
|
| オブジェクトの配列 | 任意 | クエリ実行の Per Lucene |
collectors
collectors は、次のフィールドを含むBSONドキュメントです。
フィールド | タイプ | 必要性 | 目的 |
|---|---|---|---|
| ドキュメント | 必須 | クエリのすべてのコレクターの統計情報。報告される統計は、クエリで使用されるすべてのコレクターにわたる最大値または、すべてのサブコレクションにわたる統計の合計を表します。タイミング統計は、クエリ全体のすべてのコレクターで費やされた合計時間を反映するように合計されます。詳しくは |
allCollectorStats
allCollectorStats は、クエリで指定されたすべてのコレクターのコレクター統計を記述するBSONドキュメントです。これには、次のキーが含まれています。
フィールド | 説明 |
|---|---|
| コレクターが収集した期間と結果の数を追跡します。 |
| コレクターから |
| スコアラーがコレクターに設定された合計時間と回数を追跡する統計。 |
metadata
metadata には、次のような有用なメタデータが含まれています。
フィールド | タイプ | 必要性 | 目的 |
|---|---|---|---|
| 文字列 | 任意 |
|
| 文字列 | 任意 |
|
| 文字列 | 任意 | クエリで使用されるMongoDB ベクトル検索インデックス。 |
| ドキュメント | 任意 |
|
| 整数 | 任意 | 削除されたドキュメントを含むインデックス内のドキュメントの合計数。 |
query
explain応答は、クエリの実行統計を説明するキーと値を含むBSONドキュメントです。 結果セット内のexplainドキュメントには、次のフィールドが含まれています。
フィールド | タイプ | 必要性 | 目的 |
|---|---|---|---|
| string | 任意 | クエリされた埋め込みフィールドへのパス(ルートでない場合にのみ)。 |
| string | 必須 | ベクトル検索クエリーのタイプの名前。詳しくは、 |
| ドキュメント | 必須 | ベクトル検索クエリー情報。詳しくは、 |
| ドキュメント | 任意 |
|
args
explain 応答には、クエリが内部的に実行された方法に関する情報が含まれます。argsフィールドには、次の詳細が含まれます。
クエリ タイプ
各クエリ タイプの構造化された概要の例
構造化サマリー内のクエリ オプション
次のセクションでは、クエリのタイプと構造化サマリーのフィールドについて説明します。
WrappedKnnQuery複数のクエリを組み合わせた Annベクトル検索に使用されるラッパークエリ。構造化されたサマリーには、次のオプションの詳細が含まれます。
フィールドタイプ必要性説明query配列
必須
ベクトル検索で使用されるサブクエリの配列。通常、
KnnFloatVectorQueryとDocAndScoreQueryが含まれます。
KnnFloatVectorQuery浮動小数ベクトルに対する ANN 検索に固有のクエリ タイプ。構造化されたサマリーには、次のオプションに関する詳細が含まれています。
フィールドタイプ必要性説明field文字列
必須
検索対象のベクトルフィールドパス。
k整数
必須
検索する最近傍の数。
ExactVectorSearchQueryENNベクトル検索のクエリ タイプ。構造化されたサマリーには、次のオプションに関する詳細が含まれています。
フィールドタイプ必要性説明field文字列
必須
検索対象のベクトルフィールドパス。
similarityFunction文字列
必須
使用される類似性関数(
dotProduct、cosine、またはeuclidean)。filterドキュメント
任意
ベクトル検索範囲を制限するプレフィルター クエリ。
BooleanQueryベクトル検索クエリーで事前フィルターを使用する場合、説明結果には
BooleanQuery型が含まれます。このタイプのフィールドおよび事前フィルター クエリに固有のその他のクエリ タイプの詳細については、MongoDB Search 説明ページの「 クエリ タイプ 」を参照してください。
stats
executionStats と allPlansExecution の冗長モードのexplain レスポンスにはstats 、クエリ実行のさまざまな段階でクエリ に費やされた 時間 に関する情報を含む フィールドが含まれています。
タイミングの内訳
クエリの領域
統計は、クエリの次の領域で利用できます。
resourceUsage
resourceUsage ドキュメントには、クエリの実行に使用されるリソースが表示されます。次のフィールドが含まれています。
フィールド | タイプ | 必要性 | 目的 |
|---|---|---|---|
| Long | 必須 | クエリ実行中にシステムがメモリ内で必要なデータを見つけられず、ディスクなどのバッキング ストアから読み込む場合に発生するメジャーなページ フォールトの数。 |
| Long | 必須 | データがページキャッシュにあるが、まだプロセスのページテーブルにマップされていない場合に発生するマイナーページフォールトの数。 |
| Long | 必須 | ユーザー空間で費やされた CPU 時間(ミリ秒単位)。 |
| Long | 必須 | システム空間で費やされた CPU 時間(ミリ秒単位)。 |
| 整数 | 必須 | すべてのバッチでのクエリ実行中に |
| 整数 | 必須 | クエリのプロセシング中に |
vectorTracing
vectorTracing 配列にはドキュメントごとに 1 つのオブジェクトのリストが含まれています。これには、ドキュメント内のベクトルに関する次の詳細があります。
フィールド | タイプ | 必要性 | 目的 |
|---|---|---|---|
| ブール値 | 必須 | クエリの実行中にトレースされたベクトルが訪問されたかどうかを指定するフラグ。 |
| 文字列 | 条件付き | ベクトルを削除する理由。これは、ベクトルが訪問され、結果から削除された場合にのみ存在します。値は次のとおりです。
|
| 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 | 条件付き | 正確なフェーズの時間(ミリ秒単位)。これは、 |
| 整数 | 任意 | クエリでプレフィルターを指定した場合に、クエリフィルターに一致したドキュメントの数。 |
| 整数 | 必須 | セグメント内のドキュメントの合計数。 |
例
次の例では、サンプルAnn と ENN クエリで explain メソッドを使用します。自分の環境で次の例を実行するには、まず を使用してMongoDB ベクトル検索クイック mongoshスタートを完了する必要があります。
allPlansExecution
plot_embedding_voyage_3_large次の例では、allPlansExecution の冗長モードを使用して、 フィールドの DN と ENNベクトル検索クエリーで explain メソッドを実行します。
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次の例では、queryPlanner の冗長モードを使用して、 フィールドの DN と ENNベクトル検索クエリーで explain メソッドを実行します。
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次の例では、executionStats の冗長モードを使用して、 フィールドの DN と ENNベクトル検索クエリーで explain メソッドを実行します。
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 }) }