This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pprint(db.restaurants.find({'grades.grade':'Z'}).explain()["executionStats"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create multikey index | |
db.restaurants.create_index('grades.grade', | |
name='grade') | |
# List indexes | |
pprint(db.restaurants.index_information()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Query stats for query to find restaurants with grade Z | |
pprint(db.restaurants.find({'grades.grade':'Z'}).explain()["executionStats"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop indexes | |
db.restaurants.drop_indexes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'allPlansExecution': [], | |
'executionStages': {'advanced': 152, | |
'alreadyHasObj': 0, | |
'docsExamined': 152, | |
'executionTimeMillisEstimate': 0, | |
'inputStage': {'advanced': 152, | |
'direction': 'forward', | |
'dupsDropped': 0, | |
'dupsTested': 0, | |
'executionTimeMillisEstimate': 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execution stats for query for all restaurants in Manhattan | |
pprint(db.restaurants.find({'borough':'Manhattan'}).explain()['executionStats']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execution stats for query to find all Indian restaurants in Manhattan | |
pprint(db.restaurants.find({'borough':'Manhattan','cuisine':'Indian'}).explain()['executionStats']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Compound index | |
db.restaurants.create_index([('borough',pymongo.ASCENDING), | |
('cuisine',pymongo.ASCENDING)], | |
name='borough_cuisine') | |
# Get indexes | |
pprint(db.restaurants.index_information()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All Indian restaurants in Manhattan | |
pprint(db.restaurants.find({'borough':'Manhattan','cuisine':'Indian'}).explain()['executionStats']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drop index | |
db.restaurants.drop_index('_id_') | |
# Get indexes | |
db.restaurants.index_information() |