PostgreSQL Topic Archive

SQL Server PostgreSQL Articles

Wait statistics, tempdb, Query Store, Always On availability groups, and SQL Server operations notes.

SQL Server Statistics: The Fuel the Cardinality Estimator Runs On
12 min read

The index existed and the seek was in the plan, but the estimate said one row and the table said fourteen million. How auto-update thresholds, sampling, and the ascending-key trap produce bad estimates, and how to triage them with sys.dm_db_stats_properties.

SQL Server AG Lag Is Two Numbers: Send Queue vs Redo Queue
10 min read

The dashboard said SYNCHRONIZED while the readable secondary served twenty-minute-old data. Send queue and redo queue are different numbers; here is what each one means, what synchronous commit really guarantees, and how to measure RPO.

RESOURCE_SEMAPHORE Waits: When SQL Server Queries Queue for Memory
12 min read

Every weekday at 9:05 the order system's p99 went from forty milliseconds to eleven seconds, caused by one report holding a twelve-gigabyte memory grant. How grants are sized, how to read the queue in sys.dm_exec_query_memory_grants, and how to fence the pattern.

SQL Server Sliding Window Partitioning: Lifecycle, Not Speed
13 min read

The nightly purge had been deleting for six hours and generating 400 GB of log when they called me; the sliding-window replacement runs in 200 milliseconds. Partition functions, aligned indexes, SWITCH mechanics, and when partitioning is the wrong tool.

SQL Server Blocking Chains: Walking the Chain to the Lead Blocker
12 min read

The app said the database was down; the database said CPU was twelve percent and forty-three sessions were queued behind one sleeping connection holding a lock. How I walk a blocking chain to its head and decide whether to kill or wait.

SQL Server Transaction Log VLF Management for Fast Recovery
9 min read

A failover that should have taken two minutes took forty-seven because the log had 30,000 virtual log files. How autogrowth wrote that layout, what log_reuse_wait_desc is telling you, and how to rebuild the layout exactly once.

SQL Server Sliding Window Partitioning: Lifecycle, Not Speed
13 min read

The nightly purge had been deleting for six hours and generating 400 GB of log when they called me; the sliding-window replacement runs in 200 milliseconds. Partition functions, aligned indexes, SWITCH mechanics, and when partitioning is the wrong tool.

SQL Server Blocking Chains: Walking the Chain to the Lead Blocker
12 min read

The app said the database was down; the database said CPU was twelve percent and forty-three sessions were queued behind one sleeping connection holding a lock. How I walk a blocking chain to its head and decide whether to kill or wait.

How to Read a SQL Server Deadlock Graph Without Guesswork
10 min read

A week of error 1205s and a proposed retry loop that would fix nothing. How to pull deadlock graphs from system_health, read victim, owner, and waiter nodes, and kill the three patterns behind most deadlocks.

READ_COMMITTED_SNAPSHOT: Turn It On, but Know What Changes
8 min read

One database setting ended our reader-writer blocking overnight and introduced two bugs we only caught in a concurrency soak. RCSI mechanics, the honest migration checklist, and the version-store monitoring that keeps tempdb safe.

SQL Server Query Store: Hunting Regressions After a Deploy
8 min read

The deploy that doubled p95 left its fingerprints in sys.query_store_runtime_stats. How to configure Query Store so the data is there when you need it, compare intervals to find the regressed plan, and force a plan without fooling yourself.

SQL Server tempdb Contention: Fixes That Actually Work
8 min read

A batch job that got slower as we added workers was queueing on three pages in tempdb. How to tell PAGELATCH from PAGEIOLATCH, size the data files, weigh memory-optimized metadata in 2019, and keep the version store from eating the drive.

SQL Server Wait Statistics Triage with sys.dm_os_wait_stats
8 min read

Since-restart wait totals average your quietest night and your worst deploy into one meaningless number. Here is how I diff sys.dm_os_wait_stats over an interval, drop the benign noise list, and branch on what CXPACKET, PAGEIOLATCH, WRITELOG, and LCK_M_* are actually telling you.