Unbounded Query

.findMany() / .select('*') with no limit

warningPerformanceno-unbounded-query

Why this matters

A query without a LIMIT returns every row in the table. As your data grows, this query gets slower, uses more memory, and eventually crashes your server or browser.

Bad
export async function GET() {
  // Returns ALL users — could be millions
  const users = await db.user.findMany();
  return Response.json(users);
}
Good
export async function GET(req: Request) {
  const url = new URL(req.url);
  const page = parseInt(url.searchParams.get("page") ?? "1");
  const users = await db.user.findMany({
    take: 50,
    skip: (page - 1) * 50,
    orderBy: { createdAt: "desc" },
  });
  return Response.json(users);
}

How to fix

Add a LIMIT (take) and pagination to every query that returns a list. Default to a reasonable page size (20-100 items).

All rules