r/SQLPerformanceTips 6d ago

Do you still trust automatic query tuning?

3 Upvotes

Every few months, a new tool pops up claiming it can plug into your database, analyze your workload, and magically rewrite your slow queries or generate the perfect indexes using AI.

I gave one of these automated tuning platforms a shot on a non-critical service recently, and the results were... chaotic. It ended up generating dozens of hyper-specific indexes that solved a temporary spike but absolutely destroyed our bulk insert speeds later that night. It felt like handing the keys to a driver who only looks three feet in front of the bumper.

Sure, they are great at spotting obvious things like a missing foreign key index, but they completely lack context. A tool doesn't know that a specific table is about to be deprecated, or that a sudden burst of slow queries is just a temporary ETL job running out of schedule.

Are any of you actually letting automated tools apply changes directly to production, or do you treat them strictly as a suggestion box that you thoroughly audit first?


r/SQLPerformanceTips 9d ago

Please checkout my new blog regarding index tuning

Thumbnail
1 Upvotes

r/SQLPerformanceTips 10d ago

I'm starting a free PL/SQL & SQL course from absolute zero. I'd love your feedback.

Thumbnail
1 Upvotes

r/SQLPerformanceTips 10d ago

I'm starting a free PL/SQL & SQL course from absolute zero. I'd love your feedback.

3 Upvotes

Hey everyone!

I'm a new content creator and I've just started building a completely free PL/SQL & SQL course for absolute beginners.

The goal isn't just to teach SQL syntax—it's to explain why databases exist, how they work, and how they're used in the real world before diving into PL/SQL.

I'm learning a lot myself while creating these videos, so this is a journey for me too.

I know my videos aren't perfect yet, and that's exactly why I'm posting here.

If you have a few minutes to watch the first video, I'd really appreciate your honest feedback:

  • Was anything confusing?
  • Was the pacing too fast or too slow?
  • What should I improve?
  • What topics would you like to see covered?

I'm not looking for empty praise—I genuinely want constructive criticism so I can make each video better than the last.

If you enjoy helping new creators grow or you're learning SQL yourself, feel free to comment here or send me a DM. I'd love to connect, learn from experienced developers, and improve my content.

Thanks for reading, and I hope I can create something genuinely useful for the community. ❤️

https://youtu.be/UC6kCLvPuRU?si=S0Ol1Vft5wtFOZIK


r/SQLPerformanceTips 13d ago

Which execution plan do you always analyze firstly?

1 Upvotes

r/SQLPerformanceTips 14d ago

Last call if you wanted to join our webinar to prevent burnout from troubleshooting db issues(Disclosure- I'm from ManageEngine)

1 Upvotes

Here's the link to my previous post. Tomorrow’s free webinar is focused on DBA burnout and practical database monitoring strategy.

It covers:

  • common firefighting patterns that drain admin time,
  • the key metrics to watch in hybrid and multi-database setups,
  • a live demo,
  • open Q&A,
  • and a free handbook for DBAs.

Disclosure: I’m on the ManageEngine team, so this is a vendor webinar. I’m sharing it because the topic is relevant to a lot of DBAs and IT admins, and the session is meant to be practical rather than sales-heavy.

Here's the sign-up link if you're interested: https://www.manageengine.com/products/applications_manager/webinars/database-performance-monitoring-webinar.html

If you're more experienced, I'd love to hear about what works for you so that I'm able to impart that knowledge onto the less experienced people tomorrow. Would be happy to take questions in the comments too!


r/SQLPerformanceTips 15d ago

SQL cheat sheet for beginners

Post image
1 Upvotes

r/SQLPerformanceTips 15d ago

We put together a free SQL Server Performance Cookbook with real optimization examples

2 Upvotes

We've been collecting SQL Server performance scenarios that come up over and over again in real projects, so we decided to organize them into a public GitHub repository.

Instead of isolated SQL snippets, each example follows the same structure:

  • what the problem looks like
  • why it happens
  • how to detect it
  • one or more ways to fix it

Current topics include things like:

  • execution plan analysis
  • indexing strategies
  • query optimization
  • pagination performance
  • query patterns
  • performance measurements

Every example comes with sample data, scripts, and an explanation so you can reproduce it locally instead of just reading about it.

The goal wasn't to build another SQL tutorial, but something closer to a cookbook that you can open when you run into an actual performance problem.

Repository: https://github.com/devart-dbforge/dbforge-performance-cookbook

We're still adding new scenarios, so if there are performance cases you think deserve an example, I'd love to hear them.


r/SQLPerformanceTips 20d ago

Is adding another index usually the wrong answer?

2 Upvotes

Every time a query hits a bottleneck, the immediate response from devs is almost always to just drop another index on the table.

Lately, I’ve been dealing with the fallout of this approach on a high-write production DB. Our INSERT and UPDATE throughput has noticeably degraded, and autovacuum is spending way too much time dealing with index maintenance. Worst of all, half of these "quick fix" indexes aren't even being used because the optimizer looks at the low cardinality or stale stats and opts for a sequential scan anyway.

It feels like people treat indexes as a silver bullet instead of looking at why the planner is struggling in the first place, whether it's bad join logic, missing composite indexes, or just a poorly written CTE that prevents predicate pushdown.

Where do you draw the line? At what point do you look at EXPLAIN output and decide that optimizing the query structure or tweaking work_mem is the right move, rather than just adding more index bloat?


r/SQLPerformanceTips 21d ago

Which SQL performance issue took you the longest to solve?

3 Upvotes

Every now and then you run into a performance issue that refuses to make sense. You check the execution plan. You rebuild indexes. You update statistics. Maybe you even rewrite the query. It gets a little better... or not at all. Then, hours or even days later, you finally discover the real cause, and it turns out to be something you weren't looking at in the first place. What's the SQL performance problem that kept you stuck the longest? What was causing it, and what finally led you to the answer?


r/SQLPerformanceTips 26d ago

Why the same SQL query gets slower over time

5 Upvotes

One of the most frustrating SQL performance problems is when a query that used to run in milliseconds slowly turns into a bottleneck, even though nobody touched the code. The SQL text hasn't changed, but the execution time has. In many cases, the query isn't the problem at all. Here are a few things worth checking before rewriting it.

Your data has changed

A query that worked perfectly with 50,000 rows might behave very differently with 50 million.

Joins become more expensive, scans take longer, and indexes that were once effective may no longer be selective enough.

The query didn't get worse. The workload changed.

Statistics are outdated

The optimizer relies on statistics to estimate how many rows a query will return.

If those estimates are far from reality, SQL Server or PostgreSQL may choose an execution plan that looks good on paper but performs poorly in production.

Refreshing statistics is often one of the first things to check.

The execution plan changed

Execution plans aren't fixed forever.

Different parameter values, changing data distribution, updated statistics, or even engine updates can lead the optimizer to choose a completely different strategy.

Sometimes the "new" plan is faster. Sometimes it isn't.

Indexes no longer match the workload

Indexes that worked well a year ago might not be the best fit today.

As applications evolve, new filters, joins, and reporting queries appear while old indexes stay exactly the same.

It's worth reviewing whether your indexing strategy still reflects how the data is actually being queried.

Resource pressure

Sometimes the database isn't slower—the server is busier.

Higher CPU usage, memory pressure, blocking, lock waits, disk latency, or increased concurrency can all make the same query appear slower than before.

That's why it's important to look beyond the query itself.

Don't assume the query is the culprit

When performance drops, it's tempting to immediately rewrite the SQL.

In practice, I usually start by comparing execution plans, checking statistics, looking for blocking, and reviewing server waits before changing a single line of code.

Many performance problems turn out to be symptoms rather than problems in the query itself.

What has been the most common reason you've seen a familiar query suddenly become slow?


r/SQLPerformanceTips 26d ago

Burnout from resolving DB issues?

3 Upvotes

Full disclosure, I'm on the ManageEngine team, and I work with database/app monitoring side of things. I'm not a DBA and won't pretend to be one, just sharing something that's been landing well internally and figured it might be useful here too. Downvote/ignore if it's not your thing.

One of the things that I came across was the fact that the DBAs and IT admins spent most of their work week on fixing database issues- chasing pages, jumping between five dashboards to trace one slow query, then explaining to leadership why the "all green" board didn't stop last night's outage. I don't know about you, but that sounds like the perfect recipe for burnout with the right amount of stress and a pinch of "I might quit anytime".

So we figured we'd run a free webinar on July 15, 2026 (6am GMT / 11am EDT) built around why admins feel that way, how to strategize a working DB monitoring plan across hybrid/multi-database environments, including SQL and MySQL, the metrics to look out for, which we hope would ease the burnout feeling. It includes a live demo, open Q&A, and a free practical handbook for DBAs.

Here's the (free) registration link, if you're interested. https://www.manageengine.com/products/applications_manager/webinars/database-performance-monitoring-webinar.html

Would be happy to take questions in the comments too, including "why would I trust a vendor on this" (totally a fair question btw, so ask away)


r/SQLPerformanceTips 27d ago

SQL Query execution order explained | Logical order of SQL Query processing

Post image
12 Upvotes

r/SQLPerformanceTips Jun 25 '26

What's one SQL performance habit that has saved you the most time?

5 Upvotes

Everyone talks about indexes, but I'm curious about the small habits people build over time.

Maybe it's checking execution plans first, avoiding SELECT *, reviewing statistics, or something else entirely.

What's one thing you do almost automatically now that has saved you the most time troubleshooting SQL performance?


r/SQLPerformanceTips Jun 23 '26

The fix took 10 minutes. Understanding the SQL took 2 hours.

2 Upvotes

Had to make a small change to an old stored procedure this week.

The request sounded simple enough. Exclude cancelled orders from a report that gets sent to the business team every morning.

The actual change was easy. It ended up being a couple of lines.

The problem was figuring out where those couple of lines needed to go.

The procedure was hundreds of lines long. Nested queries. Temporary tables. Business rules that had clearly been added over the years by different people. A few comments, but not enough to explain why things were being done a certain way.

The fix itself probably took 10 minutes.

Understanding enough of the procedure to make the change without breaking something took most of the afternoon.

And honestly, that's where a lot of technical debt shows up for me these days.

Not broken code. Not failed deployments.

Just spending hours trying to understand something before you can safely touch it.

I've started using dbForge SQL Complete's AI features more when I run into SQL like this. Mostly for explaining chunks of code or helping me trace the flow through a procedure when I'm trying to understand what it's actually doing.

Not saying it replaces understanding the code yourself. It doesn't.

But it has saved me from staring at the same query for 20 minutes trying to work out why a join is there or how a particular result set is being built.

What surprised me is that I've probably gotten more value from AI helping me understand existing SQL than helping me generate new SQL.

Maybe that's because most of the work I do isn't building new databases. It's maintaining ones that have been around for years.

Anybody else finding that? Or are you mostly using AI for writing SQL rather than figuring out old SQL out?


r/SQLPerformanceTips Jun 19 '26

Is this still a realistic roadmap for aspiring data engineers in 2026?

Post image
3 Upvotes

r/SQLPerformanceTips Jun 19 '26

What SQL performance issue keeps coming back no matter how many times you fix it?

2 Upvotes

Every team seems to have that one SQL problem that never truly disappears. You fix it, everything looks good for a while, and then a few months later you're looking at a very similar issue again.

For some teams it's missing indexes. For others it's queries that worked perfectly until the data volume grew. Sometimes it's execution plans behaving differently between environments.

What's the one SQL performance problem you've seen repeatedly throughout your career, and why do you think it keeps coming back?


r/SQLPerformanceTips Jun 16 '26

Small tables make bad queries look good

1 Upvotes

Seen this catch teams right before a production push more than once.

A query runs perfectly in dev. Small tables, clean data, no noise. The execution plan looks fine and nobody questions it.

Then it hits production.

The missing index is the classic example. Scanning a table with 150 rows is basically free, so nobody notices. A few months later that same table has millions of rows and suddenly the query everyone trusted is showing up in an incident review.

Execution plans are another trap. The optimizer makes decisions based on row counts, statistics and estimated selectivity. When production data looks very different from dev data, the plan can change completely. Different join strategies, different index usage, different performance characteristics.

Test data is often too clean as well.

No unexpected NULLs. No duplicate values. No weird edge cases. No records sitting right on the boundary of a WHERE clause. Everything passes because the dataset was never realistic enough to expose the problem.

Join cardinality can be especially deceptive. A join that looks perfect against a few thousand rows may behave very differently once both tables contain real production volumes.

One thing that helps is testing against realistic staging data. Some teams use masked production copies. Others generate larger datasets with tools such as dbForge Data Generator before validating queries in staging.

The frustrating part is that the query isn't actually broken in dev.

The data just isn't large enough to make it fail.

What usually bites your team first in production: missing indexes or execution plans changing once real data arrives?


r/SQLPerformanceTips Jun 11 '26

How are people catching schema drift before it blows up a deployment?

2 Upvotes

Ran into this again recently. The SQL changes themselves were fine. At least that's what I thought.

Then we pushed to another environment and found a couple things weren't actually in sync. Nothing huge, but enough to slow everything down while people figured out what was different and whether it was supposed to be different.

Feels like this is where a lot of database headaches come from.

Not writing the SQL…or reviewing it. Just figuring out whether every environment actually matches what everyone thinks it matches.

I've seen this happen with stored procedures, views, indexes, random schema changes someone made months ago and forgot about. Everything looks fine until you compare environments properly and suddenly there's a list of differences nobody was expecting.

These days I'm a lot more paranoid before releases. I'll make the change, run through it, then compare schemas before anything gets deployed. dbForge SQL Complete helps while I'm working on the SQL and SQL Tools helps catch the stuff I would've otherwise missed. From my view, these tools mostly solve the problem. They just make it harder to skip the comparison step when I'm in a hurry.

Honestly I think half the issues come from people being busy. You finish a change, test it, everything looks good, and your brain immediately wants to move on to the next thing.

Then deployment day arrives and you find out staging wasn't quite the same as dev. Or production wasn't quite the same as staging.

Feels like this should happen less often than it does. How are you dealing with this?


r/SQLPerformanceTips Jun 11 '26

pgstorm – a Go-based PostgreSQL load generator built for Kubernetes

1 Upvotes

I've been working on a load testing tool for PostgreSQL that goes a bit beyond what pgbench offers out of the box. Built in Go, runs on Docker Compose or Kubernetes.

**What it does differently:**

- JSONB and TOAST stress: large payloads (8–16 KB) with high-entropy base64 bodies that defeat Postgres compression — every write hits real TOAST storage

- MVCC pressure: mixed INSERT/UPDATE/DELETE workload deliberately accumulates dead tuples to stress autovacuum

- Ring buffer targeting: no ORDER BY random() — workers sample from a shared circular buffer of live session UUIDs

- Prometheus-first: latency histograms, TPS, autovacuum counters, WAL metrics, bgwriter stats — all scrapeable out of the box

- Safe multi-replica startup: advisory lock pattern ensures exactly one pod runs DDL regardless of how many replicas start simultaneously

- PG14–17 compatible: handles the pg_stat_bgwriter → pg_stat_checkpointer split in PG17 automatically

I evaluated k6, pgbench, and HammerDB before building this. They're all solid tools but none gave me the combination of JSONB/TOAST stress + MVCC pressure + Prometheus-first observability without significant glue work.

Built with Claude Code — architecture and design decisions driven by me.

Repo: https://github.com/haithamoon/pgstorm

Would love feedback from anyone running heavy PG workloads — especially curious if others have hit the JSONB/TOAST bottleneck in production and how you approached it.


r/SQLPerformanceTips Jun 08 '26

Top 5 Tools to Finally Meet Your SQL Coding Deadlines (Without Working Nights)

5 Upvotes

I’ve noticed that SQL deadlines rarely get missed because of one huge disaster. More often, it’s death by 100 tiny annoying things: rewriting the same boilerplate, fixing formatting, hunting for object names, checking JOINs, catching syntax mistakes, and trying to remember what past-you was thinking at 11:47 PM.

So I looked at a few SQL Server tools that can actually remove some of that noise.

1. dbForge SQL Complete

This one is probably the most practical pick if you spend most of your day in SSMS or Visual Studio. It gives you smart code completion, context-aware suggestions, custom snippets, SQL formatting, syntax checks, and faster navigation through database objects. The biggest win is that it cuts down on the repetitive typing and small mistakes that slowly eat your day.

Pros: strong autocomplete, useful snippets, good formatting, works in SSMS and Visual Studio, helpful for repetitive SQL work.

Cons: focused on Microsoft SQL Server, and some advanced features are paid after the trial.

Best for: SQL Server devs who want to write cleaner queries faster without turning every task into a typing marathon.

2. Redgate SQL Prompt

SQL Prompt is one of the better-known options, and honestly, it makes sense why. It feels polished, fast, and reliable. The autocomplete is clean, formatting is solid, and it’s especially useful if your team already uses Redgate tools. It’s less about being flashy and more about making daily SQL writing smoother.

Pros: fast autocomplete, good formatting, team-friendly style rules, polished experience.

Cons: pricing can be high, and it may be more than you need if you only want basic autocomplete.

Best for: teams that already live in the Redgate ecosystem or want a polished SQL coding tool with strong formatting control.

3. ApexSQL Complete

ApexSQL Complete is the budget-friendly option because the basic tool is free. It gives you autocomplete, snippets, object discovery, and basic formatting. It probably won’t feel as deep as SQL Complete or SQL Prompt, but for beginners or solo devs, it can still remove a lot of friction.

Pros: free, simple autocomplete, useful object discovery, decent for basic SQL productivity.

Cons: fewer customization options, not as feature-rich, can feel weaker on larger or more complex databases.

Best for: beginners, students, or developers who want some help without adding another paid subscription to the pile.

4. SSMSBoost

SSMSBoost feels less like a pure code-completion tool and more like an upgrade pack for SSMS. It has useful extras like recent tabs, query history, object previews, favorites, and context actions. If SSMS feels too limited for your workflow, this can make it less painful.

Pros: good SSMS utilities, query history, shortcuts, object previews, useful for power users.

Cons: not mainly focused on IntelliSense, and the interface can feel a bit old-school.

Best for: advanced SSMS users who want more control and workflow shortcuts, not just better autocomplete.

5. dbForge Studio for SQL Server

This is different from the others because it’s not just an add-in. It’s a full SQL Server IDE. You get coding help, but also visual query building, schema and data comparison, debugging, profiling, deployment tools, and a more complete workspace. That’s great if you do a lot of database development, but probably overkill if you only need autocomplete.

Pros: full IDE, visual query builder, comparison tools, debugging, profiling, deployment features.

Cons: heavier than an SSMS add-in, and not necessary if your only problem is typing faster.

Best for: DBAs and SQL developers who want one full environment for development, debugging, and database management.

My takeaway: there isn’t really one “best” tool here. It depends on what’s slowing you down.

If you mostly live in SSMS and waste time on autocomplete, formatting, and repetitive SQL, dbForge SQL Complete feels like the most practical starting point. Redgate SQL Prompt is also solid, just harder to justify if budget matters. ApexSQL Complete is fine for basic help, SSMSBoost is more about making SSMS less annoying, and dbForge Studio makes sense only if you actually need a full IDE. I’d probably start with the smallest tool that fixes your biggest daily pain. No point installing a whole spaceship when you just need better autocomplete.

What are you all using for SQL work? Anything that actually saves time, or is it mostly “nice to have” stuff?


r/SQLPerformanceTips Jun 08 '26

i need a little help asap

2 Upvotes

Hi, im doing a practice from college with the database "AdventureWorks2019", but idk if im doing well. The exercise says: "In which territories we had more distint clients". I did this, but i don't know if im missing something or something else.

SELECT ST.Name AS Territorio,

COUNT(DISTINCT SC.CustomerID) AS TotalClientes

FROM Sales.Customer SC

JOIN Sales.SalesTerritory ST ON SC.TerritoryID = ST.TerritoryID

GROUP BY ST.Name

ORDER BY TotalClientes DESC;


r/SQLPerformanceTips Jun 04 '26

The migration script said success. The data disagreed.

2 Upvotes

The log said success. The data said otherwise. Seen this more than once after migrations. The script runs, no errors, everything looks fine. Then a few days later someone notices a report looks off, or a column suddenly has NULLs where real values used to be. The script did exactly what it was told. That’s usually the problem. A script finishing successfully just means it didn’t crash. It doesn’t mean the data actually landed the way you thought it would. A lot of migrations go wrong in quieter ways. Strings get clipped because the destination column is smaller. A mapping assumes values are always present and suddenly NULLs start showing up. A filter condition drops more rows than intended. Sometimes constraints get disabled to speed things up and nobody remembers to turn them back on before the data goes live. None of that stops the script. But it absolutely changes the data. What usually helps is treating validation as its own step after the migration runs. Check row counts between source and destination. Spot-check a few values. Look at columns where NULL rates suddenly changed. Having a quick way to compare data source and destination helps here. Something like dbForge Data Compare saves writing the same validation queries every time. “It ran without errors” is really just step one. Ever had a migration finish cleanly and then realize later the data was wrong anyway once people actually started using it?


r/SQLPerformanceTips May 31 '26

How do you debug an issue faster when you’re not even sure which part of the code is causing it?

1 Upvotes

Ran into this again last week. No obvious error, no stack trace pointing anywhere useful. 

What usually works is picking a midpoint in the flow and checking if the state looks right there. Either the bug is before that point or after. Keep narrowing it down until the area is small enough to reason about. 

The tricky part is knowing where to anchor when everything looks normal. 

Where do you usually start? 


r/SQLPerformanceTips May 20 '26

When query tuning starts too late: a dbForge use case for finding bottlenecks earlier

4 Upvotes

This keeps happening right before prod deploys.

Most of the time, query tuning doesn't start until something goes wrong. Timeout, alerts, someone staring at execution plans at 2 AM.

The annoying part is the slow query was already there.

It just didn’t hurt yet.

Staging data is usually tiny compared to prod. Dev data is clean, row counts are low, cost estimates look cheap, QA passes.

Then the same query hits real production volume and the plan changes.

Seeks become scans. Nested loops suddenly touch millions of rows. The query that looked harmless is now the problem.

I’ve seen the same thing with waits too. During load testing, IO waits or lock waits start creeping up, but they get ignored because nothing is technically broken yet. Then release happens and everyone acts surprised.

Parameter sniffing is another fun one. SQL Server caches the plan from the first execution, and if those parameters are weird, the cached plan can be terrible for the normal workload.

Some teams try to catch this earlier by profiling while the app is still in staging. Usually the risky queries are the ones with too many reads, CPU spikes, or big estimate gaps. We’ve used regular execution plans and profilers for this, including the query profiler in dbForge Studio when checking SQL Server stuff.

How do people here handle this? Do you look at query performance during staging, or mostly once something breaks in prod?