Databases 8 min read

When a Missing Index Cost $5,000: Lessons from a PlanetScale Mishap

An engineer’s oversight in a PlanetScale schema—omitting a foreign‑key‑based index—led to massive row‑scan costs, prompting a $5,000 bill, while the article also critiques junior developers’ naive schema designs and offers advice on proper database indexing and mentorship.

ITPUB
ITPUB
ITPUB
When a Missing Index Cost $5,000: Lessons from a PlanetScale Mishap

1. The hidden cost of missing indexes

Brian Anglin’s team built a Superwall SDK and used PlanetScale’s serverless database. They created two tables, ApplicationUser and ApplicationUserAlias, linked many‑to‑one, but PlanetScale’s Vitess layer does not support foreign keys, so the expected automatic index was never created.

Because the index was missing, a query that should have scanned only a few rows actually inspected the entire users table, which grew to over one million rows within a month. PlanetScale charges by the number of rows read, not by rows returned, so each request cost about $0.15. At roughly 280 requests per hour, the daily cost approached $1,000.

The team eventually fixed the issue by manually creating the missing index, but the bill had already highlighted the importance of understanding how foreign‑key relationships affect indexing.

The problematic query (shown in the next image) attempted to retrieve all aliases for a user, but without an index the database had to scan the whole table.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLJunior DevelopersPlanetScale
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.