seeing raw queries and explain output

15 views
Skip to first unread message

swashbuck1r

unread,
Sep 3, 2010, 4:34:16 PM9/3/10
to mongo-scala-driver
First off, thanks for the shapes abstraction and the collection
wrappers...that makes using Mongo with Scala top-notch.

I'd like to examine the underlying queries being sent to Mongo and run
explain on them to verify my indexes. What's the best way to do this
if I am using the Shapes or Query API?

Thanks,
Spike

Alexander Azarov

unread,
Sep 6, 2010, 12:15:49 PM9/6/10
to mongod...@googlegroups.com

04.09.2010, в 0:34, swashbuck1r написал(а):

> First off, thanks for the shapes abstraction and the collection
> wrappers...that makes using Mongo with Scala top-notch.

Thanks!

> I'd like to examine the underlying queries being sent to Mongo and run
> explain on them to verify my indexes. What's the best way to do this
> if I am using the Shapes or Query API?

val shapeQuery = AShape where {AShape.field is_== Const}
val query = shapeQuery.query
// returns com.osinka.mongodb.Query object, it contains the
// constraints (argument to find) and few DBCursor modifiers
// (e.g. sorting):

val dboQuery: DBObject = query.query
val skip: Option[Int] = query.skip
val limit: Option[Int] = query.limit
val sorting: Option[DBObject] = query.sorting

However, there is no way to extract DBCursor object. You could call explain() if it would be possible, but no way. You'll have to use mongo-java-driver:

val dboExplain = collection.find(dboObject).limit(l).skip(s).sort(dboSorting).explain()

> Thanks,
> Spike
>
>

Reply all
Reply to author
Forward
0 new messages