Skip to main content

A terrible schema from a clueless programmer

In a blog post, Rachelbythebay recounts a story of encountering a poorly designed database schema that caused significant performance issues. The schema was used in a system intended to block spam emails. Instead of using lists of known open proxy hosts, the system stored the data in a single table. However, the problem lied in the way the data was stored. Each piece of information was stored as a separate string column, resulting in heavy and inefficient rows.

When performing a query to check for a match, the database had to read through each row and compare the query's characters to the stored data. This process was slow and resource-intensive. The programmer emphasizes that the schema should have been normalized, with separate tables for each set of values. The use of foreign key relationships and proper indexing would have significantly improved performance.

After realizing the issues with the initial implementation, the programmer redesigned the schema. The system was reworked to have separate tables, with each table having a simple schema with an ID and value column. The "quads" table was then modified to use the numeric IDs from the other tables as foreign keys. Multi-column unique constraints and indexing were added to improve efficiency.

The revised schema allowed for quick and efficient processing of the data, achieving the system's goal of mitigating open proxy abuses. The programmer acknowledges their initial mistakes and highlights the importance of mentorship, guidance, and learning from experienced professionals in the industry. They urge others to share their experiences and knowledge to address the widespread problem of inexperienced programmers making critical mistakes.

You can read the full article here.

Tagged as

database · schema design · performance issues · normalization · foreign keys · mentorship · programming