sql

  • The reporting database that is not a replica

    A read replica serving reports, and reports that want a different schema. Eleven indexes on production tables that exist only for reporting.

  • Building an MCP server for a database

    turkerdev/mysql-mcp, and what a protocol for tool access actually requires. The authorisation model is the host’s problem, which means it is all yours.

  • An expand-and-contract for a column type

    A VARCHAR(32) becoming an ENUM, on a table with four hundred writes a second. Four releases for a column type is the honest cost of not being able…

  • A schema change on a table nobody can lock

    A column type change on a table taking four hundred writes a second, and an ALTER that estimates four hours.

  • The archive table nobody could delete from

    900 million rows, a retention policy, and a legal question nobody had asked. A table that grows forever because deleting from it might be illegal.

  • The read model that finally earned its place

    A projection deleted in 2023 for being premature, rebuilt in 2025 because the query is now eleven seconds.

  • A generated column that removed a JSON scan

    A key inside a JSON column filtered on four hundred thousand times a day, promoted without changing any application code. The optimiser matching a functional expression to a…

  • Two years of query logs, read once

    A slow query log rotating for two years and never aggregated, and performance work driven by whoever complained loudest.

  • A CHECK constraint that caught a bad import

    A constraint added for documentation, which then rejected eleven thousand rows from a supplier feed. The constraint caught the absurd case and not the plausible one, which is…

  • The composite key I got the wrong way round, again

    Equality before range, for the fourth time in ten years, on an index created in a hurry. This is the most common index mistake and knowing it does…