PostgreSQL Aggregates and Grouping Cheat Sheet
Summarize PostgreSQL data with count, sum, averages, filtered and ordered aggregates, HAVING, GROUPING SETS, ROLLUP, CUBE, and grouping indicators.
Open cheat sheet6 organized subcategories
Queries, joins, aggregation, filtering, and data updates.
Choose a focus
48 focused guides grouped by the kind of task you need to complete.
Retrieve, combine, aggregate, and navigate relational data.
Browse subcategory 9 guidesDesign tables, constraints, identifiers, and PostgreSQL data representations.
Browse subcategory 5 guidesModify, import, transform, automate, and expose database data.
Browse subcategory 6 guidesUnderstand indexes, plans, statistics, caching, partitioning, and parallel work.
Browse subcategory 7 guidesCoordinate concurrent work and protect database objects and data.
Browse subcategory 12 guidesConfigure, monitor, back up, replicate, and maintain PostgreSQL systems.
Browse subcategory9 cheat sheets
Retrieve, combine, aggregate, and navigate relational data.
Summarize PostgreSQL data with count, sum, averages, filtered and ordered aggregates, HAVING, GROUPING SETS, ROLLUP, CUBE, and grouping indicators.
Open cheat sheetStructure PostgreSQL queries with scalar, table, correlated, EXISTS, LATERAL, common table, recursive, and data-modifying expressions.
Open cheat sheetStream PostgreSQL query results safely with cursors, bounded FETCH batches, holdability, row locking, refcursor APIs, and resumable alternatives.
Open cheat sheetWrite PostgreSQL LATERAL and set-returning-function queries for top-N lookups, JSON, arrays, time series, optional expansion, and efficient plans.
Open cheat sheetHandle PostgreSQL unknown values with IS NULL, three-valued logic, COALESCE, NULLIF, CASE, comparison predicates, and null-aware ordering.
Open cheat sheetBuild safe PostgreSQL recursive CTEs for hierarchies and graphs with anchors, termination, paths, SEARCH ordering, CYCLE detection, and bounded execution.
Open cheat sheetAnalyze PostgreSQL rows with ranking, offsets, partitioned aggregates, explicit frames, named windows, and post-window filtering.
Open cheat sheetCombine related PostgreSQL tables with inner, outer, cross, self, multi-table, aggregate, and lateral joins using clear predicates.
Open cheat sheetQuery, filter, sort, group, join, and compose relational data with practical SQL SELECT examples.
Open cheat sheet9 cheat sheets
Design tables, constraints, identifiers, and PostgreSQL data representations.
Query PostgreSQL arrays, ranges, and multiranges with correct bounds, containment, expansion, exclusion constraints, and GIN or GiST indexing.
Open cheat sheetStore PostgreSQL binary data safely with bytea, encoding functions, TOAST, large objects, privileges, cleanup, backup, and replication planning.
Open cheat sheetDesign PostgreSQL text ordering and comparison with ICU, builtin, and libc collations, safe indexes, version audits, and Unicode-aware rules.
Open cheat sheetDesign and evolve PostgreSQL domains, enums, and composite types with safe constraints, explicit casts, privileges, migrations, and replication-aware rollouts.
Open cheat sheetStore, convert, compare, bucket, format, and calculate PostgreSQL dates, timestamps, time zones, and intervals without ambiguous temporal logic.
Open cheat sheetDesign PostgreSQL identity keys, generated columns, and sequences with safe overrides, correct privileges, migration repairs, and concurrency-aware semantics.
Open cheat sheetStore, query, construct, update, index, expand, and validate PostgreSQL JSONB documents while keeping relational constraints where they belong.
Open cheat sheetDesign reliable PostgreSQL tables with identity columns, defaults, checks, keys, foreign keys, referential actions, and safe constraint changes.
Open cheat sheetUse PostgreSQL temporary and unlogged tables safely with explicit lifetimes, statistics, privileges, WAL tradeoffs, backups, locks, and replication limits.
Open cheat sheet5 cheat sheets
Modify, import, transform, automate, and expose database data.
Import and export PostgreSQL data safely with COPY and psql \copy, strict CSV contracts, staging tables, bounded reject handling, query exports, privileges, and progress monitoring.
Open cheat sheetCreate safe PostgreSQL SQL and PL/pgSQL functions, procedures, trigger functions, exception blocks, security-definer routines, volatility declarations, and tests.
Open cheat sheetSearch PostgreSQL text with LIKE, POSIX regular expressions, normalized tsvector documents, safe tsquery constructors, ranking, headlines, and GIN indexes.
Open cheat sheetCreate, secure, update, refresh, index, inspect, replace, and remove PostgreSQL views and materialized views with clear freshness contracts.
Open cheat sheetInsert, update, delete, upsert, return, and safely group SQL data changes with PostgreSQL transactions.
Open cheat sheet6 cheat sheets
Understand indexes, plans, statistics, caching, partitioning, and parallel work.
Design PostgreSQL indexes, inspect query plans, read estimates and runtime metrics, maintain statistics, and deploy indexes safely on busy tables.
Open cheat sheetTune and verify PostgreSQL parallel plans and LLVM JIT with EXPLAIN, worker limits, cost thresholds, function safety, and workload-aware testing.
Open cheat sheetPrepare, inspect, tune, and safely retire PostgreSQL statements while diagnosing generic plans, custom plans, invalidation, poolers, and parameter skew.
Open cheat sheetDiagnose row-estimate errors with ANALYZE, pg_stats, statistics targets, extended statistics, EXPLAIN, and partition-aware maintenance.
Open cheat sheetInspect PostgreSQL metadata safely with information_schema, pg_catalog, regclass casts, privilege helpers, dependency catalogs, and portable queries.
Open cheat sheetDesign PostgreSQL range, list, and hash partitions; preserve constraints and indexes; verify partition pruning; and operate rolling partition sets safely.
Open cheat sheet7 cheat sheets
Coordinate concurrent work and protect database objects and data.
Coordinate application-defined work with PostgreSQL transaction and session advisory locks, try-locks, shared modes, timeouts, ordering, and monitoring.
Open cheat sheetPrevent and diagnose PostgreSQL blocking with consistent lock order, bounded transactions, timeout scopes, wait graphs, cancellation, and safe retries.
Open cheat sheetInstall, audit, update, package, and replicate PostgreSQL extensions with pinned versions, secure schemas, trusted-script controls, and rehearsed rollback plans.
Open cheat sheetUse pgcrypto responsibly for hashing, HMAC, password verification, PGP encryption, random data, privileges, key handling, and FIPS-aware deployments.
Open cheat sheetDesign and audit PostgreSQL row-level security with command-specific policies, USING and WITH CHECK, permissive and restrictive rules, FORCE RLS, and tenant-safe testing.
Open cheat sheetOrganize and secure PostgreSQL objects with schemas, search_path, login and group roles, ownership, GRANT, REVOKE, default privileges, and privilege inspection.
Open cheat sheetControl PostgreSQL units of work with BEGIN, COMMIT, ROLLBACK, savepoints, isolation levels, read-only mode, row locks, NOWAIT, SKIP LOCKED, and retries.
Open cheat sheet12 cheat sheets
Configure, monitor, back up, replicate, and maintain PostgreSQL systems.
Plan and verify PostgreSQL logical dumps, custom archives, parallel restore, role and database globals, physical base backups, WAL archiving, and point-in-time recovery.
Open cheat sheetDesign, audit, and roll out PostgreSQL 18 client authentication with ordered pg_hba.conf rules, SCRAM, TLS, certificates, GSSAPI, LDAP, and safe secret handling.
Open cheat sheetOperate PostgreSQL settings safely across cluster, database, role, session, and transaction scopes with validation, privileges, and rollback plans.
Open cheat sheetBuild reliable PostgreSQL event signals with LISTEN, NOTIFY, transactional outboxes, queue monitoring, secure payloads, and reconnect recovery.
Open cheat sheetOperate PostgreSQL logical publications and subscriptions with safe initial copies, replica identity, filtering, security, monitoring, and failover planning.
Open cheat sheetMonitor PostgreSQL sessions, blockers, long transactions, query statistics, I/O, replication, and maintenance progress with production-safe diagnostics.
Open cheat sheetConfigure postgres_fdw securely, import foreign schemas, verify remote pushdown, tune transfers, write safely, and diagnose remote PostgreSQL access.
Open cheat sheetOperate PostgreSQL safely with psql connection options, output controls, variables, scripts, transactions, introspection, and automation patterns.
Open cheat sheetOperate PostgreSQL physical streaming standbys with base backups, WAL retention, replication slots, lag monitoring, synchronous durability, and safe failover.
Open cheat sheetPlace and tune PostgreSQL relations with tablespaces, fillfactor, TOAST settings, per-table autovacuum controls, safe moves, and storage observability.
Open cheat sheetOperate PostgreSQL VACUUM and autovacuum safely, inspect dead tuples, protect transaction ID age, diagnose cleanup blockers, and limit table bloat.
Open cheat sheetOperate PostgreSQL WAL and checkpoints safely with durability settings, replication awareness, capacity monitoring, and crash-recovery tradeoffs.
Open cheat sheet