我的環境:版本:2.4.4,操作系統:Linux 64位,成分:複製集+分片的MongoDB:複製集+分片:某種錯誤
當我連接到使用mongos
我的數據庫,將出現一個錯誤:
mongos> db.test.find().limit(500).sort({TIME:-1})
error: {
"$err" : "BSONObj size: 268823536 (0xF0EB0510) is invalid. Size must be between 0 and 16793600(16MB) First element: \u001f: ?type=38",
"code" : 10334
}
然而,當我排序的另一個領域,沒有任何錯誤:
mongos> db.test.find().limit(500).sort({C_ID:-1})
{ "_id" : "13744759060340298528dbaaa", "C_ID" : "999", "TIME" : ISODate("2013-07-22T06:51:46.034Z"), "SE" : "0", "AREA" : "a21", "CT1" : "1", "CT2" : "1", "S_PT" : 11, "EN_N" : "Test system", "T_ID" : "3946", "EN_T" : "2", "MSG" : "for test64", "EVENT" : "test event39", "S_IP" : "1.2.4.174", "URL" : "URL536" }
......
所以我連接到shardings之一:
sh0:PRIMARY> db.test.find().limit(500).sort({TIME:-1})
{ "_id" : "13744759061349b294b309aaa", "C_ID" : "373", "TIME" : ISODate("2013-07-22T06:51:46.134Z"), "SE" : "0", "AREA" : "a2", "CT1" : "1", "CT2" : "8", "S_PT" : 8, "EN_N" : "Test system", "T_ID" : "2654", "EN_T" : "1", "MSG" : "for test0", "EVENT" : "test event38", "S_IP" : "1.2.4.193", "URL" : "URL829" }
...
任何人給我一個想法?
感謝您的關注!
在分片環境中,您必須將shard鍵作爲查詢中的參數之一傳遞,否則mongos將查詢所有分片併合並性能災難的結果。 C_ID是你的分片鍵嗎? – Jayz
是的,C_ID是分片鍵。 –