我創建一個封頂集合(crawl02
)併爲此封頂創建一個索引。MongoDB _id查詢封頂集合沒有_id索引,性能將會很差集合
> db.system.indexes.find()
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "test.crawl02", "name" : "_id_" }
當我乳寧的應用程序和查詢封頂收藏,MongoDB Log
總是輸出跟蹤日誌:
[conn2] warning: _id query on capped collection without an _id index, performance will be poor collection: test.crawl02
。
我的代碼語句來查詢封頂集合(C#)
var cursor = this.QueueCollection //crawl02
.Find(Query.GT("_id", this._lastId))
.SetFlags(QueryFlags.AwaitData |QueryFlags.TailableCursor
| QueryFlags.NoCursorTimeout)
.SetSortOrder(SortBy.Ascending("$natural"));
return (MongoCursorEnumerator<QueueMessage<T>>)cursor.GetEnumerator();
閱讀郵件約遊標變量:
while(true){
if (this._cursor.MoveNext())
return this._currsor.Current;
else
return null
}
我不明白爲什麼MongoDB的減弱我crawl02
不有一個索引。
==================================== 通過更新
好,我發現約Tailable光標的文章在MongoDB office website,該消息是:
Tailable cursors are only allowed on capped collections and can only return objects in natural order. Tailable queries never use indexes.
這是因爲MongoDB的日誌警告? Tailable queries never use indexes.??
===================更新2 對不起,我忘記了mongodb日誌警告是關於test.crawl02,我改變了。
對不起,我改變了我的post.it關於test.crawl02,我忘了改變。 – zhengchun 2012-03-08 12:14:48