← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Polyglot Persistence

General Advanced
debt(d8/e8/b8/t6)
d8 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d8) — wrong-store choices (MySQL LIKE for full-text, BLOBs in DB) don't trip phpstan or deptrac; they surface as production performance degradation. Slightly better than d9 because slow query logs / APM can flag the symptom.

e8 Effort Remediation debt — work required to fix once spotted

Closest to 'architectural rework' (e8) — introducing or removing a datastore requires data migration, new client libraries, ops tooling, backup strategy, and code changes across repositories/services. Not a quick_fix despite the cheery summary; the swap itself is multi-component architectural work.

b8 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (b8) — each additional store applies across web and cli contexts, shapes deployment, monitoring, transactions (no cross-DB ACID), and team expertise. Slightly above b7 because operational complexity compounds, but not b9 since individual stores can be removed.

t6 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t6) — misconception explicitly says 'more databases ≠ better architecture'; devs adding a store per feature ignore operational compounding and impossibility of cross-database transactions. Contradicts the intuitive 'right tool for the job' framing.

About DEBT scoring →

Also Known As

multi-database polyglot storage best-fit persistence

TL;DR

Using multiple different database technologies in a single application — each chosen for what it does best rather than forcing all data into one general-purpose store.

Explanation

Different data types have different optimal storage characteristics: relational data (users, orders) fits PostgreSQL; session/cache fits Redis; search fits Elasticsearch; document data fits MongoDB; time-series metrics fit InfluxDB or TimescaleDB; graph relationships fit Neo4j. Polyglot persistence picks the best tool for each use case. The challenge: operational overhead of maintaining multiple systems, consistency across systems, and transaction management across boundaries. Best applied incrementally when a clear mismatch with the current store exists.

Common Misconception

More databases always means better architecture — polyglot persistence adds operational complexity; each additional store requires expertise, monitoring, backup, and failure handling. Start with one good store and add others only when justified.

Why It Matters

A full-text search implemented in MySQL with LIKE queries that takes 2 seconds would take 50ms in Elasticsearch — the right store for the use case eliminates entire classes of performance problems.

Common Mistakes

  • Adding a new database for every new feature — operational complexity compounds quickly.
  • Cross-database transactions — they are impossible without careful application-level sagas.
  • Not considering team expertise — a MongoDB cluster maintained by a team unfamiliar with it is dangerous.
  • Premature polyglot — solve the problem with your existing store first, add a new one only when you hit a real wall.

Code Examples

✗ Vulnerable
// MySQL full-text search — hitting limits:
$results = $pdo->query(
    "SELECT * FROM glossary WHERE body LIKE '%" . $term . "%'
     OR title LIKE '%" . $term . "%'"
);
// 2 second query on 10,000 terms, no ranking, no typo tolerance
✓ Fixed
// Polyglot: MySQL for data, Meilisearch for search:
// MySQL: source of truth for term content
$term = Term::find($slug);

// Meilisearch: optimised for full-text search
$searchResults = $meilisearch->index('glossary')
    ->search($query, ['limit' => 20]);
// 5ms response, typo-tolerant, ranked by relevance

// Keep in sync via queue:
TermSaved::dispatch($term); // Listener re-indexes in Meilisearch

Added 16 Mar 2026
Edited 22 Mar 2026
Views 58
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
1 ping T 0 pings W 2 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 1 ping F 4 pings S 3 pings S 1 ping M 0 pings T 0 pings W 1 ping T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 1 ping S 1 ping M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Scrapy 8 Amazonbot 7 Perplexity 7 Google 5 SEMrush 5 Ahrefs 4 Unknown AI 2 Claude 2 Bing 2 PetalBot 2 Meta AI 1
crawler 42 crawler_json 3
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: High
⚡ Quick Fix
Use the right database for each use case: MySQL/PostgreSQL for relational OLTP, Redis for caching/sessions/queues, Elasticsearch/Meilisearch for full-text search, S3 for files — PHP can connect to all of them
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Full-text search on MySQL with LIKE; storing sessions in MySQL; binary files stored in DB BLOB; time-series data in relational table
Auto-detectable: ✗ No deptrac phpstan
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: High Context: File


✓ schema.org compliant