11. So which type of NoSQL? CAP…
Consistency
Availability
Partition
Tolerance
CP = noSQL/column
Hadoop
Big Table
H-base
MemCacheDB
(graph)?
CA = SQL/RDBMS
SQL Sever / SQL
Azure
Oracle
MySQL
AP = noSQL/document
or key/value
MongoDB
DynamoDB
CouchDB
Cassandra
Voldemort
12. DB Features for MongoDB & SQL Server
primary keys
and indexes
queries with
models for
sorting /
limiting results
a strong
typing system
aggregations
like SUM(),
COUNT(), etc…
Large object
support
13. DB Features unique to Document DBs
Collections, not Tables
Query language, not T-SQL
Idrefs, not Joins
No pre-defined Schema
• Aggregation Framework
• Grouping or MapReduce
Aggregations
• No multi-document transactions
No Transactions
No Full-text search
15. DB Features of note in MongoDB
• BSON supports more complex types (date, geo-spatial, etc…)
• Supports dynamic queries via proprietary query language
– Uses “find()” which returns a [lazy] cursor
– Multi-key indexes can be created
• Scalability via Replication and Sharding
16. Why use MongoDB?
• Document-like
• Semi-structured
• Few Joins
• Geospatial
Data Structure
• Large or Huge
• Distributed
• Unpredictable
Data Volume
23. Modeling
Use short names
• each name is saved for
each document
• can save up to 30%
storage
Keep collections
small
• Can create non-
default (narrower) key
• Document size
maximum is 4 MB
Use GridFS for
BLOBs
33. About the Aggregation Framework
• New in MongoDB 2.2
• Layer on top to facilitate easier query-writing
34. Query Tuning
• Use best indexes
– Evaluate use of _id
– Add columns to index (specificity)
– Multiple columns, most specific first
– Can use fully covered indexing (indexOnly:true)
– Test to make sure indexes are being used
• Qty scanned s/b same as QTY returned
• Use .explain
37. Modifying Data
Update
• alone does a replace
Update w/ $set
• does an update
Update w/ $inc
• increments
Upserts
• must be enabled
• then insert if new,
update if existing
Multiple field
updates
• occur by default