2015-02-06 131 views
0

我有點絕望。由於Robomongo直接使用客戶端進行查詢變得非常糟糕,但在Rails中使用它需要很長時間(大約5分鐘)。顯然是相同的查詢。在Rails中的查詢需要更多的時間,在MongoDB中

MongoDB中查詢:

db.items.find({_slugs: {$in: ["gang-leader-for-a-day-a-rogue-sociologist-takes-to-the-streets"]}}) 

Rails中查詢:

Item.in(_slugs: "gang-leader-for-a-day-a-rogue-sociologist-takes-to-the-streets").first 

兩個查詢都在同一個數據庫上執行和 '_slugs' 被索引。

我將不勝感激任何幫助或提示。

+1

您是否嘗試過通過助力車(即'Item.collection.find(...)')查詢繞過任何Mongoid可能會做什麼? – 2015-02-06 19:27:50

回答

1

工作!

Item.collection.find({_slugs: {'$in' =>["gang-leader-for-a-day-a-rogue-sociologist-takes-to-the-streets"]}}) 

由於@mu_is_too_short :)