The Scariest Lines of Code I've Ever Written
canro91.github.io·6h·
Discuss: Hacker News
Flag this post

The Scariest Lines of Code I’ve Ever Written

06 Nov 2025 #sql

I don’t remember if it was rainy or sunny outside. It was more than five years ago. I was still becoming a senior coder.

I’ve written hundreds of thousands of lines of code. But I still remember this one. As part of my routine, I wrote this query in a stored procedure,

SELECT * FROM dbo.HugeTableWithoutIndexes
WHERE DATEDIFF(DAY, ADateColumn, @InputDate) = 0

I was working with an email system built with Amazon SES. I needed to show all email activity: delivered, opened, bounced, and so on. I wrapped a column in a function. A deadly sin!

The table had millions of records and no indexes. My quer…

Similar Posts

Loading similar posts...