<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43" -->

---
title: We Deleted 400 Lines of Code. The App Got Slower.
description: A team deleted 412 lines of code labeled as an 'unused batching helper,' only to watch feed response times jump from 94ms to 910ms (p50) and database query...
canonical: https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: We Deleted 400 Lines of Code. The App Got Slower. | daily.dev
og:description: A team deleted 412 lines of code labeled as an 'unused batching helper,' only to watch feed response times jump from 94ms to 910ms (p50) and database query...
og:url: https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43
og:image: https://api.daily.dev/og/posts/kg8LKfP43.png
og:image:alt: We Deleted 400 Lines of Code. The App Got Slower.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# We Deleted 400 Lines of Code. The App Got Slower.

**[Medium](https://daily.dev/sources/medium_js)** · 6 min read · 1 upvotes · 0 comments

## Summary

A team deleted 412 lines of code labeled as an 'unused batching helper,' only to watch feed response times jump from 94ms to 910ms (p50) and database query counts explode from 4 to 180–240 statements per request. The removed code was a DataLoader-style in-process batcher that coalesced per-card identity lookups into single bulk queries. The readable replacement — a sequential per-item await loop — silently reintroduced the N+1 problem. The fix was rolling back, restoring the batcher under a clearer name, adding a CI assertion on max Postgres statement count per feed request, and documenting the intent explicitly. The key lesson: code that coalesces I/O is not unused complexity — it's a rate limiter on physics, and it needs a test that will catch the next 'cleanup' before it ships.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.stackademic.com/we-deleted-400-lines-of-code-the-app-got-slower-0b75884b7ed3>

## Questions this post answers

### What happens if you remove a DataLoader-style batching helper from a feed API?

Removing an in-process batching helper that coalesces per-item lookups into a single query can reintroduce the N+1 query problem, since each sequential await becomes its own round trip. In one case, replacing a batcher with a simple loop calling one lookup per card raised statements per feed request from about 4 to 180-240, pushed p99 latency from 220ms to 4.1s, and drove Postgres CPU from 18% to 71%.

_Anyone auditing 'dead code' before deletion can compare real-world N+1 regressions on daily.dev._

### How can I prevent a code cleanup from silently reintroducing N+1 queries?

Add an integration test that fails when the number of database statements per request exceeds a fixed budget, rather than relying only on tests that check JSON shape or static analysis for unused code. One team set a CI check that fails a feed test if Postgres receives more than 8 statements for a 50-card fixture, plus documentation warning against replacing the batcher with per-item awaits.

_Teams guarding against N+1 regressions during refactors can find similar guardrail patterns on daily.dev._

## Similar posts on daily.dev

- [Sometimes it's just better to load "all" the data](https://daily.dev/posts/sometimes-it-s-just-better-to-load-all-the-data-rzohxoihx) · We Are .NET · 65 upvotes · 2 comments
- [Processing 11 million rows in minutes instead of hours](https://daily.dev/posts/processing-11-million-rows-in-minutes-instead-of-hours-jgagdggzi) · stitcher.io · 277 upvotes · 5 comments
- [30 Minutes to 90 Seconds: 4 Fixes to Optimise a Data Processing Pipeline](https://daily.dev/posts/30-minutes-to-90-seconds-4-fixes-to-optimise-a-data-processing-pipeline-rzsnxolln) · Medium · 0 upvotes · 0 comments
- [One line of Python, and a 3× drop in p99](https://daily.dev/posts/one-line-of-python-and-a-3-drop-in-p99-9yshjhsge) · Backstage Blog · 1 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"We Deleted 400 Lines of Code. The App Got Slower.","url":"https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43"},"datePublished":"2026-07-28T19:32:55.219Z","dateModified":"2026-09-13T21:43:44.421Z","description":"A team deleted 412 lines of code labeled as an 'unused batching helper,' only to watch feed response times jump from 94ms to 910ms (p50) and database query...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5b2d4ad6c1a68a7abdda98bc4c05169c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5b2d4ad6c1a68a7abdda98bc4c05169c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,postgresql","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"We Deleted 400 Lines of Code. The App Got Slower."}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/we-deleted-400-lines-of-code-the-app-got-slower--kg8lkfp43#faq","mainEntity":[{"@type":"Question","name":"What happens if you remove a DataLoader-style batching helper from a feed API?","acceptedAnswer":{"@type":"Answer","text":"Removing an in-process batching helper that coalesces per-item lookups into a single query can reintroduce the N+1 query problem, since each sequential await becomes its own round trip. In one case, replacing a batcher with a simple loop calling one lookup per card raised statements per feed request from about 4 to 180-240, pushed p99 latency from 220ms to 4.1s, and drove Postgres CPU from 18% to 71%. Anyone auditing 'dead code' before deletion can compare real-world N+1 regressions on daily.dev."}},{"@type":"Question","name":"How can I prevent a code cleanup from silently reintroducing N+1 queries?","acceptedAnswer":{"@type":"Answer","text":"Add an integration test that fails when the number of database statements per request exceeds a fixed budget, rather than relying only on tests that check JSON shape or static analysis for unused code. One team set a CI check that fails a feed test if Postgres receives more than 8 statements for a 50-card fixture, plus documentation warning against replacing the batcher with per-item awaits. Teams guarding against N+1 regressions during refactors can find similar guardrail patterns on daily.dev."}}]}
```

