indexing - Checking position of an entry in an index MongoDB -


i have query using pymongo outputting values based on following:

cursor = db.collect.find({"index_field":{"$regex":'\s'}} document in cursor:   print document["_id"] 

now query has been running long time (over 500 million documents) expected. wondering though if there way check query in execution perhaps finding out last printed "_id" in indexed field. last printed _id halfway through btree index? near end?

i want know see if should cancel query , reoptimize and/or let finish, have no way of knowing _id exists in query.

also, if has way optimize whitespace query, helpful to. based on doc, seems if of used ignorecase of been faster, although doesn't make sense whitespace checking.

thanks much, j

query optimization

your query cannot optimized, because it's inefficient$regex search that's looking space \s in the document. can do, search $regex prefix of \s, e.g.

db.collect.find({"index_field": {"$regex": '^\\s'}}) 

check out notes in link

indexing problem

$regex can use index efficiently when regular expression has anchor beginning (i.e. ^) of string , case-sensitive match. additionally, while /^a/, /^a.*/, , /^a.*$/ match equivalent strings, have different performance characteristics. of these expressions use index if appropriate index exists; however, /^a.*/, , /^a.*$/ slower. /^a/ can stop scanning after matching prefix.


db op's info

use db.currentop() info on of running ops.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -