<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # MongoDB 覆蓋索引查詢 官方的MongoDB的文檔中說明,覆蓋查詢是以下的查詢: * 所有的查詢字段是索引的一部分 * 所有的查詢返回字段在同一個索引中 由于所有出現在查詢中的字段是索引的一部分, MongoDB 無需在整個數據文檔中檢索匹配查詢條件和返回使用相同索引的查詢結果。 因為索引存在于RAM中,從索引中獲取數據比通過掃描文檔讀取數據要快得多。 ## 使用覆蓋索引查詢 為了測試蓋索引查詢,使用以下 users 集合: ``` { "_id": ObjectId("53402597d852426020000002"), "contact": "987654321", "dob": "01-01-1991", "gender": "M", "name": "Tom Benzamin", "user_name": "tombenzamin" } ``` 我們在 users 集合中創建聯合索引,字段為 gender 和 user_name : ``` >db.users.ensureIndex({gender:1,user_name:1}) ``` 現在,該索引會覆蓋以下查詢: ``` >db.users.find({gender:"M"},{user_name:1,_id:0}) ``` 也就是說,對于上述查詢,MongoDB的不會去數據庫文件中查找。相反,它會從索引中提取數據,這是非常快速的數據查詢。 由于我們的索引中不包括 _id 字段,_id在查詢中會默認返回,我們可以在MongoDB的查詢結果集中排除它。 下面的實例沒有排除_id,查詢就不會被覆蓋: ``` >db.users.find({gender:"M"},{user_name:1}) ``` 最后,如果是以下的查詢,不能使用覆蓋索引查詢: * 所有索引字段是一個數組
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看