Skip to content

Instantly share code, notes, and snippets.

View aniruddha27's full-sized avatar

Aniruddha Bhandari aniruddha27

View GitHub Profile
View sql_window_functions_01.sql
/* Sample data */
insert into emp (EMPID, NAME, JOB, SALARY)
values
(201, 'ANIRUDDHA', 'ANALYST', 2100),
(212, 'LAKSHAY', 'DATA ENGINEER', 2700),
(209, 'SIDDHARTH', 'DATA ENGINEER', 3000),
(232, 'ABHIRAJ', 'DATA SCIENTIST', 2500),
(205, 'RAM', 'ANALYST', 2500),
(222, 'PRANAV', 'MANAGER', 4500),
(202, 'SUNIL', 'MANAGER', 4800),
View mongo_stats_12.py
# Query stats
pprint(db.restaurants.find({'cuisine':'French','grades.score':{'$gt':5}}).explain()['executionStats'])
View mongo_stats_11.py
# Query stats
pprint(db.restaurants.find({'cuisine':'American'}).explain()['executionStats'])
View mongo_stats_10.py
pprint(db.restaurants.find().explain())
View mongo_index_17.py
# Multiple token search
db.restaurants.find_one({"$text": {"$search": "Chinese -Restaurant"}})
View mongo_index_16.py
# Multiple token search
db.restaurants.find_one({"$text": {"$search": "Chinese Kitchen"}})
View mongo_index_15.py
# Find restaurants with Kitchen in their name
db.restaurants.find_one({"$text": {"$search": "Kitchen"}})
View mongo_index_14.py
# Drop indexes
db.restaurants.drop_indexes()
# Create text index
db.restaurants.create_index([('name', 'text')],
name='restaurant_name')
# List indexes
pprint(db.restaurants.index_information())
View mongo_stats_9.py
# Query stats
pprint(db.restaurants.find({'cuisine':'French'}).explain()['executionStats'])
View mongo_stats_8.py
# Query stats
pprint(db.restaurants.find({'cuisine':'French','grades.score':{'$gt':2}}).explain()['executionStats'])