S
Supanote
Sign in Sign up
Database, Cache & Warehouse

Database & SQL Configuration Templates

Production blueprints for PostgreSQL 18 io_uring & UUIDv7, MySQL 8.4 LTS, MariaDB 11.8 Vector Index, SQLite 3.50, MongoDB 8.0, Redis 8.0, Memcached 1.6, and BigQuery FinOps.

ini
Verified Starter

Production PgBouncer Transaction Connection Pooling Config

Battle-tested pgbouncer.ini configuration for high-traffic PostgreSQL workloads with transaction pooling and keepalive tuning.

;; Production PgBouncer Configuration
[databases]
app_db = host=127.0.0.1 port=5432 dbname=app_production auth_user=postgres

[pgbouncer]
logfile = /var/log/postgresql/pgbouncer.log
pidfile = /var/run/postgresql/pgbouncer.pid
listen_addr =...
sql
Verified Starter

PostgreSQL Slow Query Logging & auto_explain Configuration

Production postgresql.conf snippet to log queries exceeding 250ms with execution plans, buffer usage, and lock wait times.

-- PostgreSQL 16 Slow Query Logging & Auto Explain
-- Append these directives to postgresql.conf or run as ALTER SYSTEM

-- 1. Log Queries Exceeding 250ms
log_min_duration_statement = 250

-- 2. Detail Logging for Slow Statements
log_checkpoints =...
sql
Verified Starter

PostgreSQL Logical Replication & CDC WAL Settings

Optimized postgresql.conf and publication/subscription SQL statements for change data capture and replication.

-- PostgreSQL Logical Replication & Change Data Capture (CDC) Setup

-- Step 1: Ensure postgresql.conf settings are applied:
-- wal_level = logical
-- max_wal_senders = 10
-- max_replication_slots = 10

-- Step 2: On PRIMARY Publisher...
ini PostgreSQL 18
Verified Starter

PostgreSQL 18 Asynchronous I/O (io_uring) & NVMe Config

Production PostgreSQL 18 postgresql.conf tuning asynchronous I/O (io_method = io_uring), read-ahead concurrency, and NVMe cost planners.

# PostgreSQL 18 Production NVMe & Asynchronous I/O Configuration
# Target: PostgreSQL 18+ on Linux 6.1+ (32 GB RAM / 8 vCPU / NVMe SSD)
# Place in conf.d/99-pg18-aio-nvme.conf and restart PostgreSQL (io_method requires restart)

# 1. PostgreSQL 18...
sql PostgreSQL 18
Verified Starter

PostgreSQL 18 Native uuidv7() Time-Ordered Primary Keys

Eliminate B-tree page splits and WAL bloat in PostgreSQL 18 using native DEFAULT uuidv7() primary keys and timestamp extraction.

-- PostgreSQL 18+ Native Time-Ordered UUIDv7 Primary Key Blueprint
-- Solves random UUIDv4 B-tree index fragmentation, buffer churn, and WAL write amplification

-- 1. Core Table Using Built-In uuidv7() Default (RFC 9562)
CREATE TABLE IF NOT EXISTS...
sql PostgreSQL
Verified Starter

Live PostgreSQL Lock Tree (pg_blocking_pids) & Safe Killer

Recursive PostgreSQL lock tree query using pg_blocking_pids() to pinpoint root blocker transactions holding DDL or row locks.

-- Live PostgreSQL Hierarchical Lock Tree & Root Blocker Inspector (PG 14 - PG 18)
-- Run during migration hangs or row-lock pileups to identify the exact root cause PID

WITH RECURSIVE activity AS (
    SELECT
        pid,
        usename,
       ...
Notification