borjagvo
borjagvo

Reputation: 2101

Query in Rails takes far more time that in MongoDB

I'm a little desperate. Query directly using a client as Robomongo goes smothly, but doing it in Rails takes very long (about 5 minutes). Apparently is the same query.

The query in MongoDB:

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

The query in Rails:

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

Both queries are executed on the same database and '_slugs' is indexed.

I would appreciate any help or hints.

Upvotes: 0

Views: 58

Answers (1)

borjagvo
borjagvo

Reputation: 2101

Worked!

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

Thanks to @mu_is_too_short :)

Upvotes: 1

Related Questions