stefan-luellmann.com

3 Common Mistakes Killing Your App's Speed - Stefan Lüllmann

12/7/2025Updated 2/25/2026

Excerpt

Prisma makes it dangerously easy to write inefficient database queries. Because the abstraction layer is so smooth, developers often forget that a single line of JavaScript can trigger massive, resource-intensive SQL operations. I have seen production codebases where fetching a blog post title inadvertently loaded the entire database table into memory. This is highly inefficient. As developers, we need to think about the **resource cost** of our code. Bad performance doesn't just frustrate users, it inflates cloud bills and wastes infrastructure. This article breaks down the three most common Prisma performance mistakes I have encountered, and exactly how to fix them. ## Understanding the Cost ... Consider the seemingly harmless snippet: TypeScript ``` 1await db.user.findMany({ 2 include: { posts: true } 3}) ``` This snippet fetches **every user** and **every post** associated with them. That seems manageable if you have 10 users. But what if you have 100,000 users? And each has 10 posts? You are asking your database to return over a million rows of data. … ## Mistake 1: The "Select All" Trap (Over-fetching) The ``` include ``` keyword is one of the most commonly abused features in Prisma. By default, it acts like a ``` SELECT * ``` , fetching every column from the joined table. If you only need to display the titles of a user's posts, why fetch the … What exactly is happening here? First, we fetch all users (1 query). Then, the ``` for ``` loop runs. If there are 1,000 users, the code inside the loop runs 1,000 times. This results in **1,001 total requests** to your database. This will bring even a powerful server to a crawl. **The Solution:** Let Prisma handle the relation.

Source URL

https://stefan-luellmann.com/articles/database/mistakes-killing-app-speed

Related Pain Points