Even with the code unchanged, if the DB changes how it executes a query (its query plan), a query that took 2 ms yesterday takes hundreds of ms today.
Why Automatic statistics updates, a DB restart, or shifts in data distribution make the DB build a new query plan → Effect A plan that skips the index gets picked, the same query becomes tens to hundreds of times slower, and connections get tied up → On screen With no deploy at all, loading for a specific feature suddenly slows down and other requests wait too
Primary owner Infra team (DB infrastructure) · Also Game team (Server development)
Game team action items
For queries whose result count varies widely by parameter value, split them or consider plan hints, design queries that reliably use an index.
Infra team action items
Watch slow queries and query plan history, pin good plans (Query Store in SQL Server, and so on), manage when statistics get updated.
On the graph
Step change · Average execution time per query
Where to look
Collect the average time per normalized query periodically and watch the trend. MySQL: AVG_TIMER_WAIT in events_statements_summary_by_digest. PostgreSQL: mean_exec_time in pg_stat_statements (mean_time on 12 and earlier). Compare query plans from before and after the slowdown with EXPLAIN or PostgreSQL auto_explain, and in SQL Server with the Regressed Queries view in Query Store
Confirmed if
With no deploy at the time, one query’s average time steps up tens of times, the moment lines up with a statistics update or a DB restart, and the query plan has changed
Ruled out if
Slower with the query plan unchanged: data growth, lock waits (db-hot-row), or the disk
Check with
Infra tools (no game code needed)
Learn more
SQL Server reuses a plan built for the first value it sees (parameter sniffing). A plan built for a new character with only a few items gets very slow when used for an old character with tens of thousands of items, and the reverse is common too. It may recover when a restart clears the plan, then go bad again.
Sources
Query Processing Architecture GuideMicrosoft SQL Server Parameter sniffing: the query plan is built for the parameter values passed at compile or recompile time
Monitor performance by using the Query StoreMicrosoft SQL Server Plans change with statistics, schema, and index changes, and the plan cache keeps only the latest plan; Query Store’s plan forcing pins a good plan; the Regressed Queries view compares slowed-down queries and their plans
Statement Summary TablesMySQL events_statements_summary_by_digest: COUNT_STAR and AVG_TIMER_WAIT (average time) per normalized query