Skip to content
StackPractices

Tag: postgresql

Browse 27 practical software engineering resources tagged with "postgresql". Discover code recipes, design patterns, documentation templates, and in-depth guides to help you build, deploy, and maintain production-ready solutions involving postgresql.

Connect to PostgreSQL

How to connect to PostgreSQL databases in Python, JavaScript, and Java.

Database Connection Pooling

Configure and tune database connection pools to maximize throughput while preventing connection exhaustion.

Manage Database Migrations Safely

How to version, apply, and rollback database schema changes using migration tools like Flyway, Alembic, and Liquibase in production environments.

Database Migrations Safely

How to run database schema migrations without downtime or data loss.

Set Up Database Read Replicas for Scaling

Scale read-heavy workloads with database read replicas, replication lag monitoring, and read/write splitting across primary and replica instances.

Database Replication

Set up and manage database replication for high availability, read scaling, and disaster recovery with primary-replica architectures.

Create and Use Database Views and Materialized Views

How to create and use database views and materialized views to simplify queries and improve read performance

Elasticsearch Aggregations for Analytics and Search

How to use Elasticsearch aggregations to build faceted search, analytics dashboards, and real-time metrics from indexed data

Full-Text Search

How to implement full-text search with Elasticsearch, Meilisearch, and PostgreSQL.

Implement Optimistic Locking with Versioning

How to implement optimistic locking with versioning to prevent lost updates in concurrent database access

PostgreSQL Query Optimization and Indexing Strategies

Analyze and optimize slow PostgreSQL queries using EXPLAIN, proper indexing, partial indexes, and query rewriting to reduce execution time from seconds to milliseconds

Seed Database

How to seed databases with realistic data for development, testing, and staging environments using seed scripts, migrations, and factories across PostgreSQL, MongoDB, and Prisma.

Soft Deletes

How to implement soft deletes to preserve data while hiding records from normal queries.

Find and Remove Duplicate Rows in SQL

Detect duplicate records in SQL tables using GROUP BY and HAVING, then remove them safely while keeping the canonical row.

Set Up Full-Text Search Indexes

Configure full-text search indexes in PostgreSQL to query large text columns with ranking, stemming, and highlighting.

Analyze and Optimize SQL Indexes with EXPLAIN

Identify missing, unused, and inefficient indexes by reading execution plans and measuring query cost with EXPLAIN.

SQL Joins

Practical examples of INNER, LEFT, RIGHT, and FULL OUTER JOINs with real-world query patterns.

Zero-Downtime Column Rename Migration

Rename columns or change data types without locking tables by using views, triggers, and backfill strategies.

Partition Large Tables by Date or Range

Split huge SQL tables into smaller partitions by date, range, or list to improve query performance and maintenance.

Traverse Hierarchical Data with Recursive CTEs

Query tree-like or graph-like structures in SQL using recursive common table expressions to walk parent-child relationships.

Rank Rows and Calculate Running Totals with Window Functions

Use SQL window functions to rank rows, compute running totals, and compare values within partitions without self-joins.

Implement the Transactional Outbox Pattern for Reliable

Use the transactional outbox pattern to reliably publish domain events alongside database changes, with a relay processor, polling strategies, and exactly-once delivery guarantees.

Database Query Tuning Checklist

Checklist for systematic SQL query optimization: EXPLAIN plan analysis, index strategy, N+1 query detection, join optimization, pagination patterns, connection pooling, query caching, and slow query log triage with examples for PostgreSQL and MySQL.

Full-Text Search — Implement Search That Actually Works

A practical guide to full-text search: PostgreSQL tsvector, Elasticsearch indexing, query design, relevance tuning, and building search that users trust with autocomplete, faceting, and typo tolerance.

Read Replicas: Scale Reads Without Changing Application

A practical guide to read replicas: setting up replication, routing read queries, handling replication lag, and scaling read-heavy workloads with PostgreSQL, MySQL, and cloud-managed replicas.

Complete Guide to PostgreSQL Replication

Master PostgreSQL replication. Covers streaming replication, logical replication, cascading replicas, synchronous commit, failover with Patroni, monitoring lag, slot management, and disaster recovery with practical configuration examples.

Complete Guide to PostgreSQL Tuning

Optimize PostgreSQL for high throughput. Covers configuration tuning, indexing strategies, query optimization, connection pooling, partitioning, and vacuum management.