Choosing data stores from access patterns: relational (Azure SQL), document (Cosmos DB), key-value (Redis), search (Azure AI Search) and blob storage, with consistency, query and cost trade-offs and when polyglot persistence is worth it.
I choose data stores from the access patterns, not the brand. I list how the data is written and read: key lookups, range queries, joins, full-text search, large files. Then:
I start with one relational database and add a store only when a pattern can't be served well. The trade-off is fit versus complexity: each extra store means data sync, eventual consistency, backups and another thing to run.
"I start by writing down the access patterns, because a data store is good or bad only relative to how you use it. For each entity: how is it written, how often, and how is it read — by id, by a range like 'orders for this customer in the last month', by joining to other data, by free text, or as a big file. I also note the consistency each pattern needs and the volume.
Then I map patterns to stores. Relational is my default: Azure SQL gives me joins, ACID transactions, foreign keys and unique constraints, and it comfortably handles most business systems up to terabytes. A document store like Cosmos DB fits when I have very high volume and every query knows the partition key — device telemetry by device id, a shopping cart by user id — and I can accept paying per request unit and designing around that key. Redis is for data I can lose or rebuild: caches, sessions, rate-limit counters. Search engines handle full-text and faceting, fed from the source of truth by events or an indexer. Large files always go to Blob Storage with only the metadata and URL in the database.
The mistake I see is picking a NoSQL database because it 'scales', and then needing joins and transactions it doesn't do well — or the opposite, storing PDFs in SQL Server. Polyglot persistence is fine, but every extra store needs a sync mechanism, a consistency story, backups and monitoring. I add one only when a real access pattern demands it."
| Access pattern | Best fit | Azure | AWS note |
|---|---|---|---|
| Joins, transactions, constraints, ad-hoc reporting | Relational | Azure SQL, PostgreSQL Flexible Server | RDS, Aurora |
| Point reads/writes by key at very high scale | Document / wide-column | Cosmos DB | DynamoDB |
| Sub-millisecond reads, counters, TTL data | Key-value | Azure Cache for Redis / Azure Managed Redis | ElastiCache |
| Full-text, relevance, facets | Search | Azure AI Search | OpenSearch |
| Files, images, backups | Object storage | Blob Storage | S3 |
| Append-only events, high-throughput streams | Log / stream | Event Hubs | Kinesis, MSK |
| Store | Strength | Weakness |
|---|---|---|
| Azure SQL | Rich queries, ACID, mature tooling (EF Core, Query Store) | Scale-up limits; sharding is manual |
| Cosmos DB | Horizontal scale, global distribution, tunable consistency | Partition key is hard to change; cross-partition queries are expensive |
| Redis | Very fast | Memory-bound; not durable enough for a system of record |
| Azure AI Search | Relevance and facets | Eventually consistent with the source |
| Blob Storage | Cheap per GB, tiers | No querying of content |
Orders, payments, stock --> Azure SQL (transactions, constraints)
Product catalogue search --> Azure AI Search (indexed from SQL)
Cart and sessions --> Redis (TTL, rebuildable)
Product images --> Blob Storage + Front Door
A team storing 40 million audit events a month in Cosmos DB with a partition key of /eventType found most queries were 'all events for this customer', which fanned out across partitions and cost about 10× the expected RUs. Re-keying on /customerId brought typical queries to single-partition reads under 10 ms and cut the bill by around 70%.
Checks whether the candidate chooses data stores from access patterns and understands the cost of polyglot persistence.
Green flags
Red flags
Every store makes some operations cheap by making others expensive. B-tree indexes in SQL Server make range scans and joins cheap but writes pay for every index. Cosmos DB makes point reads within a partition cheap (around 1 RU for a 1 KB item) but cross-partition queries fan out. Redis keeps everything in memory, so reads are fast but capacity is bounded by RAM. You can only judge a store once you know which operations you need to be cheap.
Need transactions across rows/entities or joins?
yes -> relational (Azure SQL)
no -> every query knows a single key?
yes -> very high scale or global? -> Cosmos DB
otherwise -> relational is still fine
no -> free text / relevance? -> search index fed from source
Large binary? -> Blob Storage, metadata in DB
Rebuildable, latency-critical? -> Redis in front of the source
In a polyglot design, exactly one store owns each piece of data. Others are projections: the search index, the cache, a reporting replica. Projections are updated by change feed (Cosmos DB), Change Data Capture or the transactional outbox (SQL Server), or scheduled indexers. If a projection is lost, you rebuild it from the source.
Writing to two stores in one request without a distributed transaction risks one write succeeding and the other failing. The outbox pattern fixes this: write the business row and an outbox row in one SQL transaction, then a background worker publishes the change. Readers of projections must tolerate lag (usually seconds).
Azure SQL is priced by vCores or DTUs plus storage; Cosmos DB by provisioned or serverless request units plus storage; Redis by memory tier; Blob Storage by GB and operations with hot, cool, cold and archive tiers. A store that's cheap at one access pattern can be expensive at another.
WHERE Description LIKE '%term%' in SQL Server with a full-text CONTAINS query on 1M rows.BackgroundService that publishes rows to a queue.GET latency with redis-benchmark versus a SQL point query from the same App Service.Polyglot persistence done safely: the order is written to Azure SQL with an outbox row in one transaction; a worker later projects it to the search index.
namespace Shop.Orders;
using Microsoft.EntityFrameworkCore;
using System.Text.Json;
public sealed record Order(Guid Id, Guid CustomerId, decimal Total, DateTimeOffset CreatedAt);
public sealed record OutboxMessage(Guid Id, string Type, string Payload, DateTimeOffset CreatedAt)
{
public DateTimeOffset? ProcessedAt { get; set; }
}
public sealed class ShopDb(DbContextOptions<ShopDb> options) : DbContext(options)
{
public DbSet<Order> Orders => Set<Order>();
public DbSet<OutboxMessage> Outbox => Set<OutboxMessage>();
}
public sealed class PlaceOrder(ShopDb db, TimeProvider clock)
{
public async Task<Guid> HandleAsync(Guid customerId, decimal total, CancellationToken ct)
{
var order = new Order(Guid.CreateVersion7(), customerId, total, clock.GetUtcNow());
db.Orders.Add(order);
// Same transaction as the order: either both are saved or neither.
db.Outbox.Add(new OutboxMessage(Guid.CreateVersion7(), "OrderPlaced",
JsonSerializer.Serialize(order), clock.GetUtcNow()));
await db.SaveChangesAsync(ct);
return order.Id;
}
}
// A BackgroundService reads unprocessed outbox rows and updates the search index
// (Azure AI Search, Redis, etc.). If it crashes, rows are retried, so the
// projection update must be idempotent (upsert by order id).
Seniors default to boring: one relational database plus Blob Storage covers a surprising share of systems, and every additional store is a long-term operational commitment — backups, upgrades, security patching, access control, monitoring and someone on call who understands it. Before adding one, they do the analysis explicitly: which access pattern fails today (with numbers), what the new store costs per month, the sync mechanism and its lag, and how the team will operate it for years.
When they do add a store, they name the source of truth, the projection mechanism (outbox, change feed, CDC) and the acceptable lag, and they monitor that lag (for example, an Azure Monitor alert when the outbox's oldest unprocessed row is older than 60 seconds). In CQRS or event-sourced designs, separate read stores are the point of the architecture, so the same discipline applies from day one. They also know relational databases have grown: SQL Server's JSON support, full-text search and columnstore indexes cover many cases that used to justify a second store.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Single Azure SQL | Relational data, < a few TB, thousands of rps | Scale-up ceiling | Global multi-region writes |
| Azure SQL + Redis | Read-heavy, latency-sensitive | Cache invalidation | Data must always be fresh |
| Cosmos DB first | Key-based access at very high scale, global | RU cost, partition design | Many joins, ad-hoc reporting |
| + Search index | Relevance, facets, typo tolerance | Sync lag, extra service | Simple equality filters |
| CQRS read store | Read shapes very different from writes | Projection code, lag | Simple CRUD |
CAP says that when a network partition splits a replicated data store, it must choose between consistency (every read sees the latest write, strictly linearisability) and availability (every working node still answers). Because partitions happen in any real network, "pick two of three" is misleading: the real choice is C or A during a partition. PACELC adds the part that matters every day: Else, when there's no partition, you trade latency against consistency, because keeping replicas in sync means waiting for them. Real systems sit at different points: SQL Server Always On with synchronous commit favours consistency at the cost of latency; Cosmos DB lets you choose one of five consistency levels; Redis replication is asynchronous and can lose acknowledged writes on failover. The trade-off is per use case, not per company.
SQL Server reads JSON with OPENJSON (shred an array into typed rows using a WITH schema), JSON_VALUE (one scalar) and JSON_QUERY (an object or array), updates it with JSON_MODIFY, and produces it with FOR JSON PATH. To filter on a property quickly, add a computed column on JSON_VALUE and index it. The native json type stores a validated binary form and adds JSON_OBJECTAGG/JSON_ARRAYAGG and the JSON_CONTAINS/JSON index features; it's GA in Azure SQL and shipped with SQL Server 2025, though some features (like the JSON index) are documented as preview.
The design rule: JSON for sparse, variable or pass-through data; real columns for anything you filter, join, constrain or report on.
LIKE '%term%' has a leading wildcard, so it can't seek and scans every row, and it matches substrings, not words ("cat" matches "education"). Full-text search builds an inverted index of word tokens using a language's word breaker and stemmer, populated asynchronously in the background. CONTAINS does precise word, phrase, prefix ("kett*"), proximity (NEAR) and inflectional searches; FREETEXT matches meaning, using stemming and the thesaurus. CONTAINSTABLE/FREETEXTTABLE add a RANK for ordering. It's available in Azure SQL Database with no extra service.
Its limits are basic relevance, no typo tolerance, facets or vector search. When search is a product feature, I'd use Azure AI Search (or Elasticsearch), kept in sync from SQL.
How to tell it (STAR)
**S:** At [company], our [activity] service on Cosmos DB was costing [several times] its estimate and throttling during business hours. **T:** I was asked to find out why and fix it without downtime. **A:** I pulled the real queries from Application Insights and found [most] filtered by customer, but the container was partitioned by event type, so every query fanned out. I raised autoscale to stop the 429s, then migrated to a container keyed on customer id using the change feed and switched reads over once it caught up. **R:** Typical queries dropped from [x] ms to under [y] ms, throttling stopped, and the monthly bill fell by about [percentage]%.
Last updated 23 Nov 2026.