<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: M Dsouza</title>
    <description>The latest articles on DEV Community by M Dsouza (@m_dsouza_6354fd6ef6b8d61e).</description>
    <link>https://dev.to/m_dsouza_6354fd6ef6b8d61e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4079053%2F40c3c133-bc95-405b-9476-baa07038a493.png</url>
      <title>DEV Community: M Dsouza</title>
      <link>https://dev.to/m_dsouza_6354fd6ef6b8d61e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/m_dsouza_6354fd6ef6b8d61e"/>
    <language>en</language>
    <item>
      <title>PostgreSQL vs MySQL: The Storage Decision That Can Make or Break Your Architecture</title>
      <dc:creator>M Dsouza</dc:creator>
      <pubDate>Sat, 15 Aug 2026 13:54:29 +0000</pubDate>
      <link>https://dev.to/m_dsouza_6354fd6ef6b8d61e/postgresql-vs-mysql-the-storage-decision-that-can-make-or-break-your-architecture-1moe</link>
      <guid>https://dev.to/m_dsouza_6354fd6ef6b8d61e/postgresql-vs-mysql-the-storage-decision-that-can-make-or-break-your-architecture-1moe</guid>
      <description>&lt;p&gt;published: true&lt;br&gt;
description: A Principal Engineer's breakdown of ACID guarantees, InnoDB vs Heap storage, replication lag nightmares, and eliminating database single points of failure.&lt;br&gt;
tags: systemdesign, architecture, postgres, mysql&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://medium.com/@talitadsouza/postgresql-vs-mysql-in-2026-why-most-teams-pick-the-wrong-database-249611b7805e" rel="noopener noreferrer"&gt;https://medium.com/@talitadsouza/postgresql-vs-mysql-in-2026-why-most-teams-pick-the-wrong-database-249611b7805e&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Now that we have covered entry points—DNS, reverse proxies, load balancers, CDNs, and in-memory caches—we are officially stepping into &lt;strong&gt;Phase 2: The Storage &amp;amp; Data Tier&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Stateless routing is relatively straightforward. Stateful storage is where a single architectural mistake causes data loss, cascading write locks, or financial discrepancies.&lt;/p&gt;

&lt;p&gt;In senior system design interviews and production systems, drawing a generic "Database" box is not enough. You must justify &lt;strong&gt;why&lt;/strong&gt; you picked a specific engine and how it behaves under failure.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Core Architecture: PostgreSQL vs MySQL (InnoDB)
&lt;/h2&gt;

&lt;p&gt;[ Client / Connection Pool ]&lt;br&gt;
│&lt;br&gt;
┌─────────────┴─────────────┐&lt;br&gt;
▼                           ▼&lt;br&gt;
[ MySQL (InnoDB) ]          [ PostgreSQL ]&lt;br&gt;
• Multi-threaded model      • Process-per-connection model&lt;br&gt;
• Clustered B+Tree index    • Heap-based storage + Secondary indexes&lt;br&gt;
• In-place updates + Undo   • Append-only tuples (MVCC vacuuming)&lt;br&gt;
• Optimized for pure OLTP   • Advanced types (JSONB, PostGIS, Vectors)&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;MySQL (InnoDB)&lt;/th&gt;
&lt;th&gt;PostgreSQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Process Model&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Multi-threaded (~256KB per connection)&lt;/td&gt;
&lt;td&gt;Process-per-connection (Needs PgBouncer)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Primary Index&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Clustered B+Tree (Data in index pages)&lt;/td&gt;
&lt;td&gt;Heap storage (Indexes reference Tuple IDs)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MVCC Updates&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;In-place update + Undo Logs&lt;/td&gt;
&lt;td&gt;Append-only tuple creation (Requires Autovacuum)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best Used For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High-throughput web applications&lt;/td&gt;
&lt;td&gt;Complex relations, JSONB, Geospatial, Vectors&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  2. The ACID Principles: The ATM Analogy
&lt;/h2&gt;

&lt;p&gt;Relational databases prioritize &lt;strong&gt;Immediate (Strong) Consistency&lt;/strong&gt; over availability during network partitions (CAP theorem).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Atomicity:&lt;/strong&gt; You withdraw $100. The cash drops &lt;strong&gt;AND&lt;/strong&gt; your ledger updates. If the dispenser jams, everything rolls back. All-or-nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Account balances never violate domain rules (e.g., negative balances without overdraft protection).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolation:&lt;/strong&gt; Concurrent balance updates process sequentially without race conditions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Durability:&lt;/strong&gt; Once committed, records are permanently flushed to the Write-Ahead Log (WAL) on disk.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. The Asynchronous Replication Catch-22
&lt;/h2&gt;

&lt;p&gt;To scale read throughput, standard practice is adding &lt;strong&gt;Read Replicas&lt;/strong&gt;. However, asynchronous replication creates a tricky edge case:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A user updates their profile picture (&lt;code&gt;Write -&amp;gt; Primary DB&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;The Primary returns &lt;code&gt;200 OK&lt;/code&gt; immediately to keep latency low.&lt;/li&gt;
&lt;li&gt;The Primary streams the WAL log over the network to the Read Replicas.&lt;/li&gt;
&lt;li&gt;The user refreshes their feed immediately (&lt;code&gt;Read -&amp;gt; Read Replica&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Bug:&lt;/strong&gt; Because of replication lag (network delay), the replica serves the old profile picture.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Client ──(1. Write Profile)──► [ Primary DB ] ──(3. Async WAL Lag)──► [ Read Replica ]&lt;br&gt;
▲                                                                           │&lt;br&gt;
└────────(4. Immediate Read returns STALE Profile!)─────────────────────────┘&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fix: Read-Your-Own-Writes Routing
&lt;/h3&gt;

&lt;p&gt;Solve replication lag at the application routing layer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set a short-lived flag/cookie on write operations (&lt;code&gt;read_primary = true&lt;/code&gt; for 5 seconds).&lt;/li&gt;
&lt;li&gt;Route that specific user's read requests to the &lt;strong&gt;Primary Database&lt;/strong&gt; for 5 seconds.&lt;/li&gt;
&lt;li&gt;Route all global static reads from other users to &lt;strong&gt;Read Replicas&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Eliminating Single Points of Failure (SPOF)
&lt;/h2&gt;

&lt;p&gt;[ Client Application ]&lt;br&gt;
│&lt;br&gt;
▼&lt;br&gt;
[ PgBouncer Pooler ]&lt;br&gt;
│&lt;br&gt;
┌───────────────┴───────────────┐&lt;br&gt;
▼                               ▼&lt;br&gt;
[ Primary Instance ] ◄──(Sync Phys)──► &lt;a href="https://dev.toActive%20Writer"&gt; Standby (Multi-AZ) &lt;/a&gt;                         (Auto-Promoted by Patroni)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Active-Passive Multi-AZ Failover:&lt;/strong&gt; Maintain a synchronous standby instance in an isolated Availability Zone. If the active primary fails, an orchestrator (such as Patroni) promotes the standby in seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connection Pooling:&lt;/strong&gt; Put &lt;strong&gt;PgBouncer&lt;/strong&gt; in front of PostgreSQL to prevent connection spikes and thread exhaustion from bringing down the cluster.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Originally published as part of my complete System Design Masterclass on Medium.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@talitadsouza" rel="noopener noreferrer"&gt;https://medium.com/@talitadsouza&lt;/a&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>postgressql</category>
      <category>interview</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
