PostgreSQL vs MySQL
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    PostgreSQL vs MySQL: the 60-second story

    PostgreSQL vs MySQL

    Two land-record offices file the same records in opposite ways.

    Office P shelves records anywhere; every catalogue gives the exact slot. Office M shelves by survey number. Meet PostgreSQL and InnoDB.

    By email: one hop in PostgreSQL, two descents in InnoDB

    Every PostgreSQL index holds the row’s ctid, its page and slot. InnoDB stores rows in the primary-key tree; secondary indexes hold the key.

    A random UUIDv4 primary key. In PostgreSQL it scatters only the primary-key index.

    In InnoDB

    It scatters the table itself: inserts split random pages and leave them half-empty. Use BIGINT or UUIDv7.

    One update: PostgreSQL touches four indexes, InnoDB only the changed one

    updated_at is indexed, so no HOT. PostgreSQL writes a new tuple; InnoDB edits in place, old value to undo.

    Uber left PostgreSQL in 2016

    Bad: So MySQL is simply faster

    Their updates rewrote every index, so switch engines.

    Good: One workload’s verdict

    The post never mentions HOT, and InnoDB pays on every secondary lookup.

    ≈ 6 GB

    worst-case query memory, 300 PostgreSQL connections

    Each connection is a process, and each sort or hash gets its own memory. Pool with PgBouncer; keep backends near the core count.

    T1 locks doctor 7’s slots 10–12. Can T2 insert 11?

    At their defaults, PostgreSQL locks only the rows it returned, so 11 slips in. InnoDB also locks the gaps; T2 waits.

    Most apps run fine on either. Break ties in order.

    1. Team first: what your on-call already runs well
    2. PostGIS, pgvector, jsonb, partial indexes → PostgreSQL
    3. Vitess, or update-heavy indexed rows → MySQL
    4. Otherwise PostgreSQL, behind PgBouncer

    Remember

    Default to PostgreSQL behind PgBouncer, and name what would switch you: a MySQL team, Vitess, or update-heavy indexed rows.