Three-panel drawing of BDBAFH #004: the mistake, what happened, and the BDBAFH's answer

The BDBAFH Chronicles #004: The EAV Database Schema & The 45-Second Profile View

A solutions architect designed an “Entity-Attribute-Value” (EAV) pattern inside Postgres to store generic entity metadata. The eav_values table had 800 million rows, 30 self-referential…

Incident #004 of the BDBAFH Chronicles: The EAV Database Schema & The 45-Second Profile View. Dark-humor fiction: no real people, companies or incidents.

Three-panel drawing of BDBAFH #004: the mistake, what happened, and the BDBAFH's answer
BDBAFH #004, The EAV Database Schema & The 45-Second Profile View, in three panels.

A solutions architect designed an “Entity-Attribute-Value” (EAV) pattern inside Postgres to store generic entity metadata. The eav_values table had 800 million rows, 30 self-referential joins, and took 12 seconds to resolve a simple user profile view.

— “It handles arbitrary schema extensions without migrations!” he boasted.

I modified the query planner cost settings (random_page_cost) specifically for his application database user key. Whenever his EAV queries ran, the optimizer intentionally chose sequential scans over multi-index scans, making every request take 45 seconds.

When he complained about performance, I handed him a book on 3rd Normal Form and told him: “Denormalize it into real columns, or enjoy your 45-second latency.”

He refactored the database schema into strongly typed tables by Monday morning.

The BDBAFH Chronicles are works of dark-humor fiction inspired by the Bastard Operator From Hell and The Daily WTF. Names, companies and incidents are invented, and any resemblance to real ones is coincidental. Commands and outputs are illustrative and untested: do not run them on a system you care about.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *