---
title: "These 5 Queries Are Destroying Your Database"
url: https://daily.dev/posts/these-5-queries-are-destroying-your-database-saxmnk5ng
source_url: https://www.youtube.com/watch?v=svFtZK4e7Hs
type: video:youtube
source: "Database Star"
published: 2026-06-07T14:16:14.890Z
updated: 2026-06-07T14:16:33.500Z
tags: ["backend", "sql"]
reading_time: 12
upvotes: 18
comments: 1
language: 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.

# These 5 Queries Are Destroying Your Database

**[Database Star](https://daily.dev/sources/database-star)** · 12 min read · 18 upvotes · 1 comments

## Summary

Five common SQL query patterns that cause silent failures, performance degradation, or data loss in production are examined with fixes. The patterns covered are: (1) NOT IN with nullable subquery columns returning zero rows due to SQL's NULL semantics — fix with LEFT JOIN or NOT EXISTS; (2) wrapping indexed columns in functions like YEAR() causing full table scans — fix by comparing raw column values against date literals; (3) SELECT * inside subqueries fetching unnecessary data and blocking predicate pushdown optimizations; (4) UPDATE statements without a WHERE clause overwriting entire tables — mitigated by running a SELECT first and wrapping in a transaction; (5) joining multiple tables before aggregating causing row multiplication and inflated counts/sums — fix by pre-aggregating each table in its own subquery before joining.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=svFtZK4e7Hs>

## Community discussion

Top comments from developers on daily.dev.

**@elvismilans** · 2 upvotes

> Number 4, killer

## Similar posts on daily.dev

- [SQL Has Rules You Don’t Notice Until Your Query Is Wrong](https://daily.dev/posts/sql-has-rules-you-don-t-notice-until-your-query-is-wrong-ue7ucmkyu) · Medium · 0 upvotes · 0 comments
- [Beautiful T-SQL Queries: Three Could Delete the Company](https://daily.dev/posts/beautiful-t-sql-queries-three-could-delete-the-company-ni51yxeeb) · SQL Authority · 36 upvotes · 7 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#sql](https://daily.dev/tags/sql)

[View this post on daily.dev](https://daily.dev/posts/these-5-queries-are-destroying-your-database-saxmnk5ng)
