The Performance Advisor orders the Indexes that it suggests by their respective Impact. Impact indicates the estimated performance improvement that the suggested index would bring.
Performance Advisor によるインデックスの推奨とランク付け方法
The Performance Advisor monitors queries that take longer than 100 milliseconds to execute and groups these queries into common query shapes. The Performance Advisor calculates the inefficiency of each query shape by considering the following aggregated metrics from queries which match the shape:
クエリの実行に費やされた時間。
スキャンされたドキュメントの数。
返されたドキュメントの数。
平均オブジェクト サイズ。
推奨インデックスを確立するために、Performance Advisor はこれらのメトリクスを式で使用して、 Impact 、またはそのクエリシェイプに一致するインデックスを作成することで発生するパフォーマンスの向上を計算します。 Performance Advisor がインデックスを提案する際、そのインデックスはImpactでランク付けされます。 Impactは、読み取られた無駄なバイトの合計に基づいてHighまたはMediumを示します。
インデックス フィールドの順序
クエリシェイプ内のクエリ操作のタイプは、インデックスの構築に使用されるフィールドの順序に影響します。 一般に、Performance Advisorは濃度によってフィールドをランク付けします。
次の表は、Performance Advisor がさまざまな操作タイプを相対的な重要性の順にランク付けする方法を示しています。
推奨インデックスの制限
Performance Advisor では、 16を超えるフィールドを持つインデックスは推奨されません。
また、Performance Advisorは、影響を受けるクエリのスキャンされたドキュメントと返されたドキュメントの差が500より大きい場合にのみインデックスを提案します。
Index De-Duplication
Performance Advisor は、提案を行う前に、重複するインデックスの重複を排除します。 たとえば、Performance Advisor が次の潜在的な推奨インデックスを計算する場合を考えてみましょう。
{ a : 1 } { a : 1, b : 1 }
{ a : 1 }は{ a : 1, b : 1 }のプレフィックスであるため、Performance Advisor は{ a : 1, b : 1 }のみを提案します。 インデックスのプレフィックスの詳細については、「プレフィックス 」を参照してください。
例: ニューヨーク市の税金データ
この例では、ニューヨーク市のタックス利用に関する情報、シャーディングとドロップダウンの時間、自転車距離、利用コストの内訳のフィールドに関する情報を含むcab-dbというデータベースを使用します。 コレクションyellow内の一般的なドキュメントは次の例のようになります。
{ "_id" : ObjectId("5db9daab0b2a17b7706cd6a3"), "pickup_datetime" : "2014-06-30 02:09:23", "dropoff_datetime" : "2014-06-30 02:20:36", "passenger_count" : 2, "trip_distance" : 3, "fare_amount" : 12, "tip_amount" : 2.6, "total_amount" : 15.6 }
このコレクションには10万を超えるドキュメントが含まれているため、特定のフィールド データに基づいてクエリを実行する必要があるアプリケーションでは、コレクションを適切にインデックス化しないと、非常に非効率的な操作が生成されます。
このアプリケーションの通常のクエリは、特定のドロップオフ時間が 1 つ以上の他のフィールドと組み合わせて含むドキュメントを検索します。 例:
db.yellow.find({ "dropoff_datetime": "2014-06-19 21:45:00", "passenger_count": 1, "trip_distance": {"$gt": 3 } })
Performance Advisor では、パフォーマンスを向上させるために次のインデックスを使用することを推奨しています。

注意
デフォルトでは、Performance Advisorには、クラスター内のすべてのコレクションのインデックスの推奨事項が表示されます。 推奨事項を特定のコレクションに絞り込むには、 Collectionドロップダウン メニューからコレクションを選択します。
Performance Advisor には、パフォーマンスへの影響が大きいものから小さいものの順に推奨インデックスが一覧表示されます。
最初の推奨は 3 つのフィールドのインデックスです。
passenger_countdropoff_datetimetrip_distance
[ Create Index ] ボタンをクリックして、必要な追加オプションを使用してインデックスを作成します。 Performance Advisor でインデックスを作成する方法の詳細については、「推奨インデックスの作成 」を参照してください。
If you create this index, you remove the need for the database engine to scan the entire collection to find documents that match the query, which improves performance. Queries with the shape shown in the example return results in 50 milliseconds or less on the indexed collection, as opposed to several seconds on the unindexed collection.