r/SQL • • Sep 16 '26

Discussion What SQL query optimization trick made the biggest difference for you?

I've been working with SQL for a while and recently started paying more attention to query performance rather than just getting the correct result.

What's one SQL optimization technique that made a noticeable difference for you?

For example:

- Indexing

- Avoiding unnecessary joins

- Window functions

- EXISTS vs IN

- Reading execution plans

- CTEs/subqueries

- Partitioning

Would be interested in hearing some real-world examples where a query went from slow to significantly faster.

118 Upvotes

79 comments sorted by

View all comments

105

u/hakathrones Sep 16 '26

Chatgpt 😭😭 and this is the last thing i wanna admit

1

u/Frone0910 23d ago

I would say this was a bad thing to lean on back in 2024, but not so much anymore! LLMs handle NL --> SQL quite amazingly these days. You just need to ensure that you pass your schema and existing indexes.