Neuro17
11/21/2013 - 11:10 AM

using_hint.py

import pymongo
import sys

client = pymongo.MongoClient('localhost', 27017)

db = client.test
week4 = db.weeek4	

def init():
	print "command init"

	try:
		for i in range(0, 10000):
			for j in range(5000, 5050):
				doc = {'a': i, 'b':j, 'c':i}
				week4.insert(doc)
				print "inserted", i, j
	except:
		print "Unexpected error", sys.exc_info()[0]	 

def hint():
	try:
		doc = week4.find({'a':6023}).hint([('b', pymongo.ASCENDING)])
		print doc.next()
	except:
		print "Unexpected error", sys.exc_info()[0]