Home / Databases

Databases

SQL Server, PostgreSQL, Oracle, MySQL, MongoDB and Redis performance and recovery. 228 posts.

MySQL / Runbook

Sev1: MySQL split brain. Two servers accepted writes after a failover

After a failover (manual or by Orchestrator, MHA or a script), the old primary came back writable and some clients kept writing to it. Fence the old primary, measure the divergence with GTIDs, reconcile the errant transactions and rebuild it as a replica.

4 min readAdvanced

SQL Server / Troubleshooting

Access violation and dump files when querying sys.dm_exec_requests during database recovery - SQL Server 2026 updates known issue and trace flag 4696

Since the September 2026 SQL Server updates, querying sys.dm_exec_requests while a database is recovering (after a restart or failover) can raise an access violation and write a dump. Monitoring tools trigger it most. Choose between trace flag 4696, pausing those queries during recovery, or removing the update.

3 min readAdvanced

SQL Server / Troubleshooting

Linked server queries fail with error 7416 after the September or October 2026 SQL Server update - MSDASQL provider strings and the stricter connection check

After the September and October 2026 SQL Server updates, linked servers that use MSDASQL with a provider string can fail with Msg 7416 - access denied because no login mapping exists. A stricter connection validation check is the cause. Check the login mappings and provider string, and look for the fix in the later builds.

3 min readIntermediate

SQL Server / Runbook

SQL Server October 2026 security updates (CVE-2026-96956 and 21 more) - which build to install, known issues to read first, and a safe rollout

Microsoft's 13 October 2026 updates for SQL Server 2017-2025 fix an elevation of privilege flaw (CVE-2026-96956) among 22 CVEs in the SQL Server 2025 update. Two known issues carried over from September affect MSDASQL linked servers and sys.dm_exec_requests during recovery. Check them, pick the right package, and patch availability groups in the right order.

3 min readIntermediate

SQL Server / How-to

A Power BI dashboard for SQL Agent job health across all your instances

Build a job health report in Power BI on top of a central Agent history store. Covers the data model, DAX measures for success rate and duration change, the pages worth building, refresh through a gateway and the read-only permissions it needs.

3 min readIntermediate

PostgreSQL / How-to

Advisory: choosing a managed PostgreSQL service - RDS, Aurora, Azure Flexible Server, Cloud SQL, AlloyDB or OCI

Managed PostgreSQL services look similar but differ in storage architecture, HA behaviour, extensions, version support and limits on superuser access. List what your applications need (extensions, versions, replication, scale), compare services on those points within your cloud, and test failover, upgrades and performance before committing.

2 min readIntermediate

MySQL / Cheat sheet

Advisory: choosing MySQL high availability - async replication, semi-sync, InnoDB Cluster, Galera or a managed service

MySQL offers several ways to survive a server failure, with different data-loss guarantees, failover speed and operational effort. Compare asynchronous and semi-synchronous replication with orchestrated failover, InnoDB Cluster/Group Replication, Galera-based clusters and managed Multi-AZ services, and decide by RPO, RTO and team skills.

2 min readIntermediate

Oracle / How-to

Advisory: designing an Oracle backup strategy with RMAN - incrementals, recovery windows, object storage and immutability

RMAN supports many backup styles, and the right one depends on database size, RPO/RTO and where backups are stored. Choose between full plus incrementals and incrementally updated image copies, set a recovery window retention, use block change tracking, send copies off-site or to object storage with immutability, and test restores.

3 min readIntermediate

PostgreSQL / Cheat sheet

Advisory: PostgreSQL backup approach - pg_dump, pgBackRest, Barman, WAL-G or managed PITR

Logical dumps and physical backups solve different problems. Use physical backups with WAL archiving for point-in-time recovery of whole clusters, logical dumps for portability and single-object restores, compare pgBackRest, Barman and WAL-G for self-managed servers, and rely on managed PITR plus extra copies on cloud services.

2 min readIntermediate

Oracle / How-to

Advisory: where to run Oracle Database in the cloud - OCI services, Oracle Database@Azure/AWS, RDS for Oracle or VMs

Oracle databases can move to several cloud targets with very different feature sets, licensing rules and operating models. Compare OCI database services, Oracle Database@Azure and @AWS, Amazon RDS for Oracle and self-managed VMs on the features you use (RAC, Exadata, options), licensing, latency to applications and who operates them.

3 min readIntermediate

SQL Server / How-to

Hidden job chains: finding SQL Agent jobs that start other jobs

Jobs that call sp_start_job create dependencies nobody sees in SSMS. Find them by searching step commands, alerts that run jobs and procedures that start jobs, then draw the chain before you disable, move or reschedule anything.

2 min readIntermediate

SQL Server / Runbook

msdb is 40 GB: purging Agent, backup and mail history on a schedule

Find out what is filling msdb, from job history, backup history, Database Mail logs or job step logs, and set up one clean-up job that purges each of them by age in batches. Also covers the indexes that keep purging fast.

3 min readIntermediate

MongoDB / How-to

Optimization: MongoDB working set, WiredTiger cache and index efficiency

MongoDB performs well while the working set and indexes fit in memory. Measure WiredTiger cache usage and eviction pressure, check index sizes and usage, remove unused indexes, design compound indexes with the ESR rule, and right-size instances or shard before the working set outgrows RAM.

2 min readIntermediate

Oracle / How-to

Optimization: sizing Oracle SGA and PGA with the built-in advisors

Oracle memory is often sized once at install and never revisited. Use the SGA, buffer cache and PGA target advisors with AWR history to see the effect of more or less memory, choose between automatic shared memory and manual settings, enable HugePages on Linux, and change in small, measured steps.

2 min readIntermediate

SQL Server / How-to

Optimization: tuning MAXDOP and cost threshold for parallelism on SQL Server

Default parallelism settings let small queries go parallel and big queries take every core, causing CXPACKET/CXCONSUMER waits and unpredictable performance. Set MAXDOP from the NUMA layout, raise cost threshold for parallelism from the default, use database-scoped and query-level overrides where needed, and confirm with wait stats.

2 min readIntermediate

SQL Server / How-to

Pausing a SQL Agent job safely: disable the job, the schedule or a step?

Three ways to stop a SQL Server Agent job from running, and what each one does to manual runs, shared schedules and other jobs. Includes T-SQL for each, a check for jobs left disabled by accident, and a habit that stops them being forgotten.

3 min readBeginner

SQL Server / How-to

Run job B only after job A succeeded today: table-driven SQL Agent job dependencies

Agent has no built-in dependency between jobs, so people chain them with sp_start_job or guess at schedule gaps. Instead, keep dependencies in a table and add a gate step that checks predecessors succeeded for today's batch. Each job can then wait, skip or fail, and the whole chain is visible in one query.

3 min readAdvanced

MongoDB / Runbook

Sev1: MongoDB replica set has no primary and writes fail

Applications get NotWritablePrimary or "no primary found", and rs.status() shows only SECONDARY members. Work out whether a voting majority is reachable, fix network or member problems, and use a forced reconfiguration only when the majority is truly gone.

3 min readAdvanced

MySQL / Runbook

Sev1: MySQL writes hang because the disk filled with binary logs

Every insert and update hangs, the error log says MySQL is waiting for disk space, and the data or binlog volume is at 100%. Free space safely by purging only binary logs that all replicas and CDC tools have read, then fix retention so it doesn't happen again.

3 min readIntermediate

SQL Server / Runbook

Sev1: nobody has sysadmin on SQL Server. Regaining access with single-user mode

The only sysadmin login was removed, sa is disabled and its password lost, or the DBA group was deleted from AD. A local Windows administrator can start SQL Server in single-user mode, connect as sysadmin and add a proper admin back. Here are the steps, the traps and the clean-up.

3 min readIntermediate

PostgreSQL / Runbook

Sev1: Patroni cluster has no leader and PostgreSQL is read-only everywhere

patronictl list shows no Leader, every node is a replica or stopped, and applications can't write. The usual causes are a lost etcd quorum, no candidate passing the failover rules, or a paused cluster. Diagnose each one and get a leader back without risking split-brain.

3 min readAdvanced

PostgreSQL / Runbook

Sev1: PostgreSQL refuses writes to avoid transaction ID wraparound

PostgreSQL warns that a database must be vacuumed within N transactions, or stops accepting writes altogether. Find what is holding back freezing, such as long transactions, abandoned replication slots or orphaned prepared transactions, remove it, and run a targeted VACUUM to get write access back.

3 min readAdvanced

Redis / Runbook

Sev1: Redis master is down and Sentinel won't fail over

The Redis master is unreachable, clients get connection errors or READONLY, and Sentinel hasn't promoted a replica. Check Sentinel quorum and majority, replica eligibility and announced addresses, then force a failover and fix clients that bypass Sentinel.

3 min readAdvanced

SQL Server / Runbook

Sev1: SQL Server database stuck in RECOVERY_PENDING or SUSPECT

A database shows RECOVERY_PENDING or SUSPECT after a restart or storage problem. Work out which it is and why from the error log. Then bring it online by fixing files and permissions, restoring from backup, or, only as a last resort, using emergency mode repair.

3 min readAdvanced

SQL Server / Cheat sheet

SQL Server Agent questions every DBA gets asked: 20 short answers

Short, practical answers to the SQL Server Agent questions that come up again and again. Where jobs are stored, who they run as, why a job didn't run, time zones, Express edition, Azure options, and more.

3 min readBeginner

SQL Server / How-to

Starting a SQL Agent job from an SSIS package and waiting until it finishes

sp_start_job returns at once, so an SSIS package that calls it carries on before the job has done anything. Build a reusable procedure that starts a job, waits for it with a timeout, and returns its outcome, then call it from an Execute SQL Task. Covers permissions too.

3 min readIntermediate

SQL Server / Troubleshooting

The job was due at 02:00 and never ran: troubleshooting SQL Agent schedules

A step-by-step check for SQL Server Agent jobs that didn't start when expected. Covers enabled flags, next run times, overlapping runs, daylight saving, Agent downtime, schedule end dates and frequency settings that don't mean what people think.

3 min readIntermediate

MySQL / How-to

Transformation: MySQL or MariaDB to PostgreSQL with pgloader

Consolidating on PostgreSQL? pgloader converts a MySQL schema and copies the data in one command. Here are the casting rules that matter, the SQL differences to fix in the application, how to validate, and how to cut over with a short freeze or CDC.

3 min readIntermediate

Oracle / Runbook

Transformation: Oracle to PostgreSQL with Ora2Pg, from assessment to cut-over

Move an Oracle schema and its data to PostgreSQL (self-managed, Azure Flexible Server or RDS/Aurora). Estimate effort with the Ora2Pg report, convert schema and PL/SQL, load data, and handle the differences that cause most bugs. Then run a parallel validation before switching.

3 min readAdvanced

PostgreSQL / Runbook

Transformation: PostgreSQL on EC2 or on-premises to Aurora PostgreSQL

Move a self-managed PostgreSQL database to Aurora PostgreSQL. Check extensions and settings, choose dump/restore, native logical replication or AWS DMS, run the cut-over, then adjust for how Aurora storage, replicas and failover behave.

3 min readIntermediate

MySQL / Runbook

Transformation: upgrading MySQL 8.0 to 8.4 LTS before 8.0 support ends

MySQL 8.0 reached end of life in April 2026, and 8.4 is the current long-term support release. Run the MySQL Shell upgrade checker, fix the changes that bite (authentication plugin defaults, removed replication syntax, changed defaults), and upgrade replicas first, then the source.

5 min readIntermediate

Oracle / Runbook

Transformation: upgrading Oracle 19c to 23ai with AutoUpgrade

Use AutoUpgrade to analyse, fix up and upgrade 19c databases to 23ai, including converting non-CDBs into PDBs. Covers the config file, the analyze, fixups and deploy modes, restore points for fallback, and the checks to run after the upgrade.

3 min readAdvanced

SQL Server / How-to

Who changed that job? Auditing SQL Agent job changes with SQL Server Audit

SQL Server Agent records that a job changed but not who changed it or what changed. Use a database audit specification on msdb's job procedures to capture who did it, keep script snapshots to capture what changed, and know the limits of triggers on msdb tables.

3 min readAdvanced

SQL Server / Troubleshooting

A SQL Agent job failed overnight: a runbook from alert to root cause

A step-by-step runbook for failed SQL Server Agent jobs. Find every failure and the step that broke, read the full error from history, output files and the Agent log, match it to the common causes (owner, permissions, proxies, timeouts, blocking, disk, Agent itself), fix and rerun safely, and stop it recurring.

5 min readIntermediate

SQL Server / Cheat sheet

A T-SQL toolkit for SQL Server Agent: list, script, change and clean up jobs in bulk

Ready-to-run msdb queries and procedure calls for everyday SQL Server Agent work. Inventory every job with its schedule and last outcome, enable or disable jobs in bulk, change owners and categories, script jobs out for source control, copy them between servers and remove the ones nobody needs.

5 min readIntermediate

SQL Server / How-to

AWS-to-AWS modernisation: SQL Server on EC2 to Amazon RDS for SQL Server

Move self-managed SQL Server on EC2 to Amazon RDS to hand over patching, backups and Multi-AZ HA. Covers the readiness check against RDS limits, sizing from CloudWatch data, migration by native backup or DMS, replacing instance-level features, and decommissioning.

2 min readIntermediate

SQL Server / How-to

Azure SQL Database to Hyperscale: when, how and what changes

Move a growing Azure SQL Database from General Purpose or Business Critical to Hyperscale for up to 128 TB, fast backups and restores, and read scale-out. Covers fit checks, the online conversion, reverse migration window, replicas, and cost.

2 min readIntermediate

SQL Server / How-to

Bring order to 200 Agent jobs with custom job categories

Job categories are a free, built-in way to group SQL Server Agent jobs by team, application or purpose. Create a simple category scheme, assign jobs in bulk, use categories in reports, bulk enable and disable, and notifications, and avoid the built-in categories that other features depend on.

5 min readBeginner

SQL Server / How-to

Cross-cloud transformation: Amazon RDS for SQL Server to Azure SQL Managed Instance

Move databases from Amazon RDS for SQL Server to Azure SQL MI, for example after a consolidation decision or an acquisition. Covers native backups from RDS to S3, copying to Azure Blob Storage with azcopy, restoring with Log Replay Service, TDE and identity considerations, and cutover.

3 min readAdvanced

SQL Server / Runbook

Day-to-day SQL Server Agent job management: the DBA's daily, weekly and monthly routine

A routine for keeping SQL Server Agent healthy. Daily checks for failures, long runs and disabled jobs, a weekly review of owners, notifications and history, and monthly housekeeping and testing. Each check comes with the query or dbatools command, and links to the deep-dive posts in this series.

5 min readBeginner

SQL Server / How-to

Eight ways to run a SQL Server Agent job, and when each one is the right choice

Start SQL Agent jobs from SSMS, T-SQL, another job, PowerShell, sqlcmd, schedules, Agent alerts or an application. Includes how to start at a specific step, wait for a job to finish (sp_start_job doesn't wait), and give non-admins permission to run only the jobs they need.

4 min readBeginner

SQL Server / How-to

Least privilege for job steps: SQL Server Agent proxies and credentials explained

CmdExec, PowerShell and SSIS job steps run as the SQL Agent service account unless you give them a proxy. Create a credential and a proxy, grant it to the right subsystems and logins, use it in a step, and troubleshoot the access errors you'll meet. Includes an audit query for every proxy on the server.

4 min readIntermediate

SQL Server / How-to

Lift and shift SQL Server to Amazon EC2: MGN, native backups or an AG replica

Rehost SQL Server on EC2 with full control. Covers instance and EBS design, three move methods (AWS Application Migration Service for whole servers, backup/restore via S3, and an AG replica over Direct Connect), licensing choices, and HA after the move.

2 min readIntermediate

SQL Server / How-to

Minimal-downtime SQL Server migration to AWS with AWS DMS full load + CDC

Use AWS Database Migration Service to copy SQL Server data to RDS or EC2 and keep it in sync with change data capture until cutover. Covers source prerequisites (MS-CDC or replication), schema-first approach, task settings for LOBs, validation, monitoring latency and cutover.

3 min readAdvanced

SQL Server / How-to

Move SSIS packages to Azure: Azure-SSIS Integration Runtime in Data Factory

Lift existing SSIS packages into Azure Data Factory with the Azure-SSIS Integration Runtime. Covers SSISDB on Azure SQL MI or Database, package deployment, connecting to on-premises sources, custom components, scheduling and cost control, plus when to rebuild instead.

3 min readIntermediate

MySQL / Cheat sheet

MySQL DBA cheat sheet: client, processlist, InnoDB, sys schema, replication and backups

The MySQL commands and queries you use every week. Covers the mysql client and mysqladmin, server status and variables, sessions and locks, slow queries with the sys schema, InnoDB health, sizes, indexes, users, binlogs, replication with GTIDs, and backups with mysqldump, MySQL Shell and XtraBackup.

4 min readIntermediate

PostgreSQL / Cheat sheet

PostgreSQL DBA cheat sheet: psql, sessions, locks, vacuum, replication and backups

The PostgreSQL commands and queries DBAs use every week. Covers psql shortcuts, server and database info, active sessions and locks, slow queries with pg_stat_statements, sizes and bloat, vacuum and autovacuum, indexes, replication, backups with pg_dump and pgBackRest, and roles.

5 min readIntermediate

SQL Server / Cheat sheet

SQL Server DBA cheat sheet: the queries and commands you use every week

One page of tested T-SQL and PowerShell for daily SQL Server work. Covers instance and database info, sessions and blocking, waits and top queries, indexes and statistics, space and tempdb, backups and restores, Always On, Agent jobs, security and dbatools one-liners.

5 min readIntermediate

SQL Server / How-to

SQL Server estate discovery and assessment before a cloud migration

Build a complete inventory of SQL Server instances, databases, features and dependencies, then assess compatibility with each target. Covers the tools for Azure and AWS, the T-SQL queries to fill the gaps, and how to turn the results into migration waves.

3 min readIntermediate

SQL Server / Runbook

The job broke when Dave left: getting SQL Agent job ownership and security right

Job ownership decides whether a job can run at all and under which security context its steps execute. Why jobs owned by personal logins fail when people leave, which owner to choose, how ownership affects T-SQL steps versus proxies, and scripts to find and fix risky owners across the estate.

4 min readIntermediate

SQL Server / How-to

What runs when? A readable SQL Agent schedule report decoded from msdb

SQL Agent stores schedules as bitmasks and packed integers. This post decodes freq_type, freq_interval, relative intervals and sub-day settings into plain English, and builds a report of every job, its schedules and next run time. Use it for on-call run books, overlap checks and maintenance-window planning.

5 min readIntermediate

SQL Server / How-to

When RDS isn't enough: moving SQL Server to Amazon RDS Custom for SQL Server

RDS Custom gives a managed SQL Server with OS and sysadmin access for apps that can't run on standard RDS. Covers when to choose it, prerequisites, the shared responsibility model, migrating with native backups, automation pause for customisations, and HA.

3 min readAdvanced

SQL Server / How-to

Why your SQL Agent history only goes back two days, and how to keep 90

SQL Server Agent keeps only 1,000 history rows by default, 100 per job, so busy servers lose history within days. Three ways to keep what you need. Raise the row limits, switch to time-based purging, or archive history to a table, with scripts and msdb sizing advice.

4 min readBeginner

MySQL / How-to

MySQL disaster recovery: cross-region asynchronous replica with GTIDs

Set up a MySQL replica in a DR region using GTID-based asynchronous replication. Covers seeding with the clone plugin or XtraBackup, securing the channel, monitoring lag, promoting the replica, and rebuilding replication for failback.

2 min readIntermediate

PostgreSQL / How-to

PostgreSQL high availability with Patroni, etcd and HAProxy

Build a three-node PostgreSQL cluster with automatic failover using Patroni and etcd, route clients with HAProxy or a VIP, choose synchronous mode settings, and run switchovers and health checks.

2 min readAdvanced

SQL Server / Runbook

SQL Server error 9002: the transaction log is full

Use log_reuse_wait_desc to see why the log can't be truncated, fix the specific cause (missing log backups, long transactions, replication, AG), and shrink only when it's safe.

2 min readIntermediate

SQL Server / Runbook

SQL Server blocking and deadlock triage

Find the head blocker in seconds, pull deadlock graphs from the system_health session, and pick the right long-term fix, from indexes to RCSI.

3 min readIntermediate