Ned Z
Ned Z

Reputation: 9

Aggregate very slow Scala

I need help because I don't know why my aggregate is very slow. I have one database with 2 collections :

users (id, name, email) with 40 000 elements

posts (id, author, content) with 39 000 elements

I want to know all post posted by an user. I use casbah and this is my code:

val aggregationOptions = AggregationOptions(AggregationOptions.CURSOR)
val content_return = 
MongoClient("localhost", 27017)("Blog")("users").aggregate(
List(MongoDBObject("$lookup" -> MongoDBObject("from" -> "posts", "localField" -> "name", "foreignField" -> "author", "as" -> "posts")),
     MongoDBObject("$unwind" -> "$posts")),
     aggregationOptions)

If anyone have an idea, thank you very much !

Upvotes: 0

Views: 113

Answers (0)

Related Questions