CosmosDB Flashcards
Considerations for choosing partition key
- transactions can only occur across a single partition
- queries work fastest when not run across all partitions
- containers can contain 1 or more partitions
What is the property to run a query across partitions?
EnableCrossPartitionQuery
What is the property to run a query in parallel?
MaxDegreeOfParallelism (client side)
Strong Consistency
- Guarantees no dirty reads
High latency because must wait for all slaves to update
Eventual Consistency
- There’s no ordering guarantee for reads. In the absence of any further writes, the replicas eventually converge.
Low latency because only one write to make
Bounded Staleness Consistency
- Dirty reads possible
Staleness configurable by time and updates (i.e. no stale data older than 30 seconds)
Session Consistency
- No dirty reads for the writer (read your own writes)
Scoped to a client session.
Dirty reads possible for the other users
Consistent Prefix Consistency
- Updates that are returned contain some prefix of all the updates, with no gaps.
Consistent prefix guarantees that reads never see out-of-order writes.
What is the _etag property?
GUID used for optimistic concurrency so Cosmos knows when one user is going to override changes of another user resulting in a conflict
Hash Index
Used for equality queries for strings and numbers.
Range Index
Equality range, order by for strings and numbers.
Spatial Index
Distance and intersection for geo coordinates
Consistent Indexing Mode
Indexed as soon as the document is added or updated.
Lazy Indexing Mode
Indexed when Cosmos has CPU cycles to spare and is not processing requests.