mongoTemplate count index(索引)
spring整合mongo給出的mongoTemplate在進行count的時候是不使用索引的(find可以)!!!!!雖然mongo執行語句時會自動幫我們進行優化,但可能並不是我們想要使用的那個索引
-
表字段
-
加上索引
-
使用客戶端進行查詢
db.play_following.find({"obj_type":"game","channel":"hao"}).hint("channel_index").count()
(hint表示使用某一個索引) 查詢結果(1.6s內返回) -
使用mongoTemplate進行查詢(60s返回,機器效能也有關係) 跟蹤原始碼可以看到在count的時候先進行了query轉化為DBObject的動作,但是我們的hint並沒有被其加以轉化,所以我們索引並沒有被使用
-
解決辦法:使用mongo原生的驅動(以下為參考):
mongoTemplate.getDb().getCollection(PlayerFollowingPO.class.getAnnotation(Document.class).collection()).count(countDBObject, new DBCollectionCountOptions().hintString(index))
相關推薦
mongoTemplate count index(索引)
spring整合mongo給出的mongoTemplate在進行count的時候是不使用索引的(find可以)!!!!!雖然mongo執行語句時會自動幫我們進行優化,但可能並不是我們想要使用的那個索引 表字段 加上索引 使用客戶端進行查詢 db.play_follo
利用js輸出ul下li的index索引值
{} 事件委托 eve rip 實現 lis dataset nodelist arr <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <ti
關於index 索引
gpo body tde 數據 刪除 day rop 數據查詢 student index : 索引:建立索引的目的是提高數據查詢的速度。 1:建立索引 index eg:對birthday 字段經常進行查詢操作,可以考慮在該字段上建立 index 。 create ind
解決phpstrom 啟動卡的問題 和index索引加載慢的問題
rec 啟動 toolbar ble lsp ber 思路 opengl exc 第一,解決啟動卡的問題 只要修改兩個Java虛擬機參數,就徹底解決了卡的問題了。 操作步驟如下: 找到C:\Program Files\JetBrains\PhpStorm 2018.2.2\
Web作業:specific word count (index of )
++ oci tel specific dem pre htm fun script 統計文件中某一詞語出現次數: HTML: <p id="p1">start,stop,speed,start,speed ,velocicty,start</p&
specific word count(index of)
統計檔案中某一詞語出現次數: HTML: <p id="p1">start,stop,speed,start,speed ,velocicty,start</p> <button onclick="fun()">Try it</button>
PostgreSql INDEX 索引總結
1.建立索引 create index index_name on table_name(field_name1, field_name2,······); 注:預設建立B-tree索引 2.查詢索引 select * from pg_indexes where tabl
Atitit lucence 使用總結 目錄 1. 基本概念 1 1.1. Index:索引庫,文件的集合組成索引。 1 2. 建立索引 2 2.1. Api查詢 2 2.2. Dsl查詢 3
Atitit lucence 使用總結 目錄 1. 基本概念 1 1.1. Index:索引庫,文件的集合組成索引。 1 2. 建立索引 2 2.1. Api查詢 2 2.2. Dsl查詢 3 Merge
不建議使用 force index()索引,使用聯合索引就可以解決問題!!!
最近解決mysql慢查詢問題,先把sql大概說明下 select id from table where type = 1 and XX= xx and XX1= xx1 and XX2 = xx2 order by time desc 再說一下背景,
specific word count(index of) specific word count (index of )
specific word count (index of ) <script type="text/javascript"> var str="Hello world!" document.write(str.indexOf("Hello") + "<
第八週作業 specific word count (index of )
specific word count (index of ) #region 統計檔案中某一詞語出現次數。 while (true) { Console.WriteLine("請輸入要查詢的詞
js 自定義陣列根據index索引刪除元素
閒來沒事,寫了個類似陣列splice()的函式,不同的是返回值不同,程式碼如下: Array.prototype.delete=function(delIndex){ var temArray=[];for(var i=0;i<this.length;i++){if(
PostgreSQL之INDEX 索引
之前總結了PostgreSQL的序列相關知識,今天總結下索引。 我們都知道,資料庫索引最主要的作用是可以提高檢索資料的速度,但是索引也不是越多越好。因為索引會增加資料庫的儲存空間,查詢資料是要花較多的時間。 1、建立索引 SQL語句如下: CREAT
對TextFile格式檔案的lzo壓縮建立index索引
hadoop中可以對檔案進行壓縮,可以採用gzip、lzo、snappy等壓縮演算法。 對於lzo壓縮,常用的有LzoCodec和lzopCodec,可以對sequenceFile和TextFile進
我們到底該不該使用 force index()索引?
工作中遇到一個棘手的問題,一個即將被丟棄的系統 有這樣的一個查詢 select * from tb_O force index(idx_create_time) inner join tb_task_A inner join tb_task_B inner join
mysql建立index索引
myisam儲存引擎下儲存資料的檔案:.frm 表定義檔案。.myd 資料檔案, .myi 索引檔案。 CREATE INDEX 語法: CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON tb
微信小程式獲取index索引值的方法
功能:點選某一項,底部出現粉色邊框 首先需要通過 bindtap 為每一個item項繫結一個點選事件,其次需要新增自定義屬性 data-* = {{index}} ,以便在函式中獲取到被點選item項的index索引值 有關自定義屬性參考 https://zhidao.baidu.com/que
淺析MySQL中的Index Condition Pushdown (ICP 索引條件下推)和Multi-Range Read(MRR 索引多範圍查找)查詢優化
修正 itl iad 較高的 一句話 mysql5 條件篩選 global 查詢條件 本文出處:http://www.cnblogs.com/wy123/p/7374078.html(保留出處並非什麽原創作品權利,本人拙作還遠遠達不到,僅僅是為了鏈接到原文,因為後續對
Mysql覆蓋索引 covering index 或者 index coverage
查詢條件 auto pla 輔助 int mes sta png post 組合索引 提到組合索引,大家都知道“最左前綴”原則。例如,創建索引 idx_name_age (name,age) ,通常情況下,where age=50 或者 where age>50 之類
Lucene——Field.Store(存儲域選項)及Field.Index(索引選項)
時間 文本 tor pan -s gpo index 進行 field Field.Store.YES或者NO(存儲域選項) 設置為YES表示或把這個域中的內容完全存儲到文件中,方便進行文本的還原 設置為NO表示把這個域的內容不存儲到文件中,但是可以被索引,此時內容無法完全