Markdown Editor

Data Store Selection Template (Relational, NoSQL, Search, Vector)

Workload profile, store categories (relational, KV, document, wide-column, search, time-series, vector), weighted matrix, derived stores

系统设计标准datastoreselection

使用方法: Use it when choosing where a workload's data lives or adding a second store. Quantify the workload and agree the matrix weights before naming products. The main pitfall is starting from a favourite technology and ignoring the cost of operating one more database type.

预览

Data Store Selection: [Workload or service]

Building-block decision record for choosing where a workload's data lives: relational, key-value, document, wide-column, search engine, time-series, graph, object storage or vector store. It describes the workload, applies a weighted decision matrix, checks the shortlist against consistency, scale, operations and cost, and records the decision and its exit plan. The categories and the matrix are an original method of this collection; for vector search it refers to the HNSW paper (Malkov and Yashunin, IEEE TPAMI, 2020). Replace every [bracketed] value and every row marked Example. Worked examples use Quillmere, an invented book-review and reading-list platform shared by the other building-block templates in this category.

Document control

FieldValue
Document ID[STORE-REC-001]
Workload[Example: Book reviews: write, edit, list by book, list by author, moderate]
Decision type[New workload / Migration / Additional store]
Version[0.1]
Status[Draft / In review / Approved / Implemented / Superseded]
Owner[@reviews-lead]
Operating team[@data-platform-lead]
Reviewers[@sre], [@security], [@finance-partner]
Last updatedYYYY-MM-DD
Classification[Internal]
RelatedDatabase Design (architecture/database-design), Build vs Buy Analysis (architecture/build-vs-buy-analysis), Replication and Consistency Models (system-design/replication-consistency-models)

Approvals

RoleNameDecisionDate
Workload owner[@name][Approved / Changes requested]YYYY-MM-DD
Operating team[@name][Decision]YYYY-MM-DD
Architecture review[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft
0.2YYYY-MM-DD[@name]Example: Search moved to a separate index after full-text requirement

1. Workload profile

AttributeExample value
Records today50,000,000 reviews
Average record size1.5 KB
Raw data50,000,000 x 1.5 KB = 75 GB; 225 GB with 3 replicas
Growth30% per year
Peak reads12,000 per second
Peak writes400 per second
Main queriesBy book (sorted by helpfulness or date), by author, by moderation status
Full-text searchYes, within reviews of a book and across all reviews
TransactionsReview and rating summary updated together
ConsistencyAuthor reads own review immediately; others may lag seconds
RetentionKept while account is active; deleted within 30 days of erasure request

2. Store categories

CategoryData modelStrong atWeak atTypical fit
RelationalTables, joins, SQL, multi-row transactionsIntegrity constraints, ad hoc queries, transactionsHorizontal write scaling without shardingOrders, accounts, most business records
Key-valueValue by keyVery high throughput, simple scalingQueries other than by keySessions, carts, feature flags, caches
DocumentNested documents by key, secondary indexesFlexible schema per record, read whole aggregateCross-document transactions and joins (varies by product)Catalogue items, user profiles
Wide-columnRows of sparse columns grouped by partition key, sorted by clustering keyLarge write volume, time-ordered data per keyAd hoc queries, joinsEvent histories, messaging, IoT per device
Search engineInverted index, relevance rankingFull-text, faceting, fuzzy matchPrimary system of record, transactionsProduct and content search
Time-seriesTimestamped points, downsampling, retentionHigh-rate ingestion, range aggregation over timeUpdates, joins with business dataMetrics, sensor data
GraphNodes and edges with propertiesMulti-hop traversalsBulk analytics over all data, wide scansFraud rings, social graph queries
Object storageImmutable blobs by keyCheap, very durable large filesSmall random updates, low-latency queriesMedia, backups, data lake files
VectorEmbeddings with approximate nearest-neighbour indexSimilarity search, retrieval for AI featuresExact filtering at scale, transactionsRecommendations, semantic search

Shortlist for this workload: [Example: Relational, document and wide-column as primary store. Search engine as a derived index for full-text queries, fed by a change stream.]

3. Weighted decision matrix

CriterionWeightRelationalDocumentWide-column
Query fit (by book, by author, sorted, moderation)30442
Consistency and transactions (review plus summary)20533
Scale headroom (5 years at 30% growth)15345
Operational maturity in this team20542
Cost (licence, infrastructure, people)15443
Weighted score (of 5.00)1004.253.802.80

Example reasons:

  • Relational scores 3 on scale: 75 GB grows to about 280 GB in 5 years at 30% per year, which one primary with replicas can hold; write rate of 400 per second is far below single-node limits.
  • Wide-column scores 2 on query fit: listing by author would need a second table per query shape, maintained by the application.
  • Operational maturity reflects that the team runs a relational store today and has no wide-column experience.

Five-year size check: 75 GB x 1.3^5 = 278 GB (computed: 1.3^5 = 3.71).

4. Product shortlist

Product optionLicence (checked YYYY-MM-DD)Managed option in our regionsSupport policyFits matrix assumptions?Notes
[Option A][Licence][Yes/No][Versions and dates][Yes/No][Notes]
[Option B][Licence][Yes/No][Versions and dates][Yes/No][Notes]
[Option C][Licence][Yes/No][Versions and dates][Yes/No][Notes]

Check each candidate against the organisation's dependency policy (long term support versions, pinned releases) and against the Build vs Buy Analysis template (architecture/build-vs-buy-analysis) when a managed service is an option.

5. Derived and secondary stores

Derived storeCategoryFed byAllowed lagRebuild from primaryExample use
Review search indexSearch engineChange stream from primary10 sFull reindex, about 2 hoursFull-text search
Review cacheKey-valueCache-aside (system-design/caching-strategy)TTL 600 sNot neededHot review lists
Book embeddingsVectorNightly batch from catalogue24 hoursRecompute, about 6 hours"Readers also liked"
[Store][Category][Feed][Lag][Procedure][Use]

Vector index sizing, Example: 5,000,000 books x 768 dimensions x 4 bytes (32-bit floats) = 15.36 GB (14.3 GiB) of raw vectors before index overhead; 8-bit quantisation reduces the raw vectors to 3.84 GB. Graph indexes such as HNSW add link storage per vector and trade recall for latency through their build and search parameters; measure recall on your own queries.

6. Non-functional checks

  • Backup and point-in-time restore tested, restore time measured against RTO.
  • Encryption in transit and at rest; key management owner named.
  • Data residency: regions where data may be stored are supported.
  • Erasure: a user's records can be found and deleted in the primary and every derived store within the retention rule.
  • Schema change process works online at the expected table size.
  • Observability: query latency, replication lag, storage growth and slow queries exported to monitoring (ops/observability-spec).
  • Capacity: partitioning plan exists if growth exceeds one node (system-design/partitioning-sharding-guide).
  • Consistency model per operation recorded (system-design/replication-consistency-models).

7. Risks and exit plan

IDRiskLikelihoodImpactMitigationExit path
DS-R01Example: Licence change of chosen productLowHighPrefer options with a widely used open licence or several vendorsLogical dump and reload into a compatible store
DS-R02Example: Search index drifts from primaryMediumMediumDaily count reconciliation, rebuild procedureRebuild from primary
DS-R03Example: Growth faster than plannedMediumMediumStorage alert at 70%, partitioning plan preparedShard by book_id
[DS-RNN][Risk][L][I][Mitigation][Exit]

8. Decision

IDDecisionReasonRevisit whenOwnerStatus
DS-01Example: Relational primary store for reviewsHighest weighted score (4.25); transactions and query fit; team already runs itWrites exceed 5,000 per second or data exceeds 2 TB@reviews-leadDecided
DS-02Example: Search engine as derived indexFull-text requirementSearch needs exceed what the primary's text search can serve@search-leadDecided
DS-03Example: Vector store for book embeddingsSimilarity queriesRecall below target@recs-leadOpen
[DS-NN][Decision][Reason][Trigger][@owner][Status]

Glossary and references

TermMeaning
Polyglot persistenceUsing different store types for different workloads in one product
Derived storeCopy or index built from a primary store, rebuildable from it
Secondary indexIndex on a field other than the primary key
Approximate nearest neighbour (ANN)Search that returns close vectors quickly without checking every vector
RecallShare of the true nearest neighbours that an ANN search returns

References:

  • Malkov Y., Yashunin D., "Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs", IEEE Transactions on Pattern Analysis and Machine Intelligence 42(4), 2020, pages 824 to 836, https://doi.org/10.1109/TPAMI.2018.2889473.
  • Related templates: Database Design (architecture/database-design), Build vs Buy Analysis (architecture/build-vs-buy-analysis), Partitioning and Sharding Plan (system-design/partitioning-sharding-guide), Replication and Consistency Models (system-design/replication-consistency-models), Caching Strategy (system-design/caching-strategy), Full-Text Search Engine System Design (system-design/design-full-text-search), Enterprise RAG Search System Design (system-design/design-enterprise-rag-search), Back-of-Envelope Estimation (system-design/back-of-envelope-estimation).

Standard and licence note

Based on general database engineering practice; no standard governs data store selection. The categories, decision matrix, weights, scores and examples are original to this collection, and Quillmere is an invented organisation. Product capabilities and licences change: check the current official documentation of each candidate on the day you decide. Template licence: MIT.

相关模板