She highlighted the offending block—a scalar-valued function inside a WHERE clause. Of course. She’d warned the team a year ago. Scalar functions were row-by-row agony. But Mark, the senior dev who had since left for a startup, had called it "elegant."

Here’s a short story inspired by SQL Server Management Studio (SSMS) .

"Execution Plan," she whispered to herself, right-clicking the query pane. The graphical plan appeared, a surreal flowchart of arrows and boxes. Somewhere in that labyrinth of nested loops and hash matches, a monster was hiding. A parallel scan costing 87% of the query. Ridiculous.

Lena leaned back. The plastic wheels of her chair squeaked. For a moment, she just stared at the Results pane: the exact same data the finance team needed for their Monday report, but delivered like a sigh instead of a scream.

Before closing SSMS, she opened the Activity Monitor one last time. The CPU graph, once a frantic seismograph during the report’s runtime, now lay flat and calm. All was well in the realm of the relational engine.

Lena’s monitor glowed like a distant lighthouse in the dark ocean of her home office. Outside, the city slept. Inside, only the soft hum of her workstation and the steady click of her keyboard broke the silence. The culprit: a stored procedure that had run flawlessly for three years—until 7:13 PM on a Friday.

-- Replaced row-by-row nightmare with set-based joy. You're welcome, future Lena.

She saved the script as Fix_SlowReport_vFinal_ActuallyFinal.sql . Then, for good measure, she added a comment at the top: