Postgres Extensions Ecosystem — Map
Cheatsheet: tên extension → mục đích → khi nào dùng. Bookmark nếu làm Postgres serious.
Tags : attachment postgres extensions
Liên quan : All Postgres tuần chapters
1. Bundled (ship with Postgres core)
Standard contrib/ extensions, available without extra install.
Install:
CREATE EXTENSION pg_stat_statements;
-- Some need shared_preload_libraries
2. Geospatial
Extension Purpose Notes PostGIS Full GIS — points, polygons, routing, raster The gold standard; OSS pgroutingRouting on PostGIS networks Network analysis h3-pgH3 hexagonal grid (Uber) Spatial indexing mobilitydbMoving objects Niche
PostGIS is must-have if any spatial query. Install:
CREATE EXTENSION postgis;
3. Time-series
4. Vector / AI
Extension Purpose Notes pgvector Vector type + HNSW/IVF index Tuan-15-Vector-DB-AI pgvectorscaleFaster vector index (StreamingDiskANN) Timescale fork pgaiLLM-in-DB calls Timescale, experimental vectorOpenAI embeddings inline Tuned for AI workloads
5. Search / Text
Extension Purpose Notes pg_trgmTrigram (bundled) Fuzzy match unaccentAccent normalize (bundled) Search prep RUMBetter full-text + ranking Faster than GIN for FTS pg_searchElasticSearch-like FTS ParadeDB; modern alternative to ES for small data
Extension Purpose Notes pg_stat_statementsBundled — query stats Must-have auto_explainBundled — auto plan log Must-have prod pgauditCompliance audit log HIPAA/SOX/PCI pg_stat_kcacheCPU + I/O per query Linux only pg_wait_samplingWait event sampling More detail than pg_stat_activity pgsentinelActive Session History (Oracle-like) Wait sampling + history hypopgHypothetical indexes (test before create) Save build time pg_hint_planForce planner hints Controversial; emergency only pg_qualstatsTrack WHERE clause stats Suggest indexes powaPerformance Workload Analyzer (UI for many extensions) All-in-one pg_stat_monitorAggregated query stats (Percona) Enhanced pg_stat_statements
7. Operations / Maintenance
Extension Purpose Notes pg_repackOnline table reorganization Bloat fix without lock pg_squeezeOnline table reorganization (alternative) — pg_partmanPartition management Tuan-Bonus-Postgres-Partitioning pg_cronIn-DB cron scheduler Schedule maintenance pg_jobsJob scheduling Alternative to pg_cron pgBackRestBackup tool (external, not extension) Tuan-07-Backup-PITR-DR pg_dirtyreadRead dead tuples (recovery) Emergency only pgttGlobal temp tables Oracle-like behavior
8. Compatibility / Migration
Extension Purpose Notes orafceOracle compat functions Migration aid tds_fdwFDW for SQL Server / Sybase Migration mysql_fdwFDW for MySQL Federation oracle_fdwFDW for Oracle Federation redis_fdwFDW for Redis — mongo_fdwFDW for MongoDB — parquet_fdwRead Parquet files Lakehouse integration pg_sqliteRead SQLite —
9. Replication / Distribution
Extension Purpose Notes pglogicalLogical replication (richer than core) Selective replication CitusDistributed Postgres (sharding) Microsoft; horizontal scale BDR (2nd Quadrant)Bi-Directional Replication EDB commercial
10. Security
Extension Purpose Notes pgcryptoBundled — encryption Column encryption pgauditAudit logging Compliance pg_tleTrusted Language Extensions (AWS) Safely install user extensions anonData anonymization GDPR set_userAudit role changes Track admin actions
11. Specialized Workloads
Extension Purpose Notes hllHyperLogLog cardinality estimation Approximate counts topnTop-N aggregate Approximate top tdigestt-digest percentile estimation Streaming percentiles bloomBloom filter index Multi-column equality segFloating-point interval type Numeric ranges prefixPrefix range type URL prefix matching pgmqMessage queue (like SQS/Kafka) DB-native queue pg_graphqlGraphQL endpoint from schema Supabase pgRoutingRouting graph algorithms With PostGIS pg_ivmIncremental materialized views Real-time CAGG (community)
12. Cloud / Vendor-specific
AWS RDS for Postgres
aws_s3, aws_lambda, aws_commons — AWS integration
pg_tle — safe user extensions
Standard extensions OK
Google Cloud SQL
google_columnar_engine (experimental)
Standard extensions OK
Azure Database for Postgres
Supabase
pg_graphql, pg_jsonschema, pgsodium, pgmq, pgvector — bundled
Plus standard extensions
13. Extension Decision Tree
flowchart TD
Need[Need extension for?] --> Q1{Query monitoring?}
Q1 -->|Yes| E1[pg_stat_statements + auto_explain]
Need --> Q2{Geospatial?}
Q2 -->|Yes| E2[PostGIS]
Need --> Q3{Time-series?}
Q3 -->|Yes| E3[TimescaleDB]
Need --> Q4{Vector / AI?}
Q4 -->|Yes| E4[pgvector]
Need --> Q5{Audit / compliance?}
Q5 -->|Yes| E5[pgaudit]
Need --> Q6{Sharding?}
Q6 -->|Yes| E6[Citus]
Need --> Q7{Backup?}
Q7 -->|Yes| E7[pgBackRest external tool]
Need --> Q8{Partition automation?}
Q8 -->|Yes| E8[pg_partman]
Need --> Q9{Reduce bloat online?}
Q9 -->|Yes| E9[pg_repack]
Need --> Q10{In-DB cron?}
Q10 -->|Yes| E10[pg_cron]
Need --> Q11{Test index before create?}
Q11 -->|Yes| E11[hypopg]
Need --> Q12{HLL counting?}
Q12 -->|Yes| E12[hll]
14. Setting up Extensions
14.1 Some require shared_preload_libraries
# postgresql.conf
shared_preload_libraries = 'pg_stat_statements,auto_explain,pgaudit,timescaledb'
Restart needed.
14.2 CREATE EXTENSION
CREATE EXTENSION pg_stat_statements;
CREATE EXTENSION IF NOT EXISTS pgvector;
CREATE EXTENSION postgis WITH VERSION '3.4' ;
-- Specific schema
CREATE EXTENSION pg_trgm WITH SCHEMA tools;
14.3 Update extensions
ALTER EXTENSION postgis UPDATE TO '3.4.2' ;
\dx -- list installed extensions
\dx + extension_name -- detail
14.4 Cloud constraints
Managed services (RDS, Cloud SQL, Azure):
Limited extension list (must be on vendor’s approved list)
Cannot install custom extensions (until pg_tle)
Cannot modify shared_preload_libraries freely
→ Check vendor’s supported extension list before designing.
15. Anti-patterns
Pattern Why bad Many extensions for fun Operational complexity Custom extensions on managed cloud Won’t install; lock-in pain Forget shared_preload_libraries requirement Extension won’t load Old extension versions on PG upgrade Compatibility issues Mix Timescale + native partitioning Conflicts pg_hint_plan in production Hides root cause Extension dependencies not documented New env setup confusion Extensions in non-public schema without search_path Functions not found
16. Recommended Production Setup
For typical web app:
shared_preload_libraries = 'pg_stat_statements,auto_explain,pgaudit'
CREATE EXTENSION pg_stat_statements;
CREATE EXTENSION auto_explain;
CREATE EXTENSION pgaudit;
CREATE EXTENSION pgcrypto;
CREATE EXTENSION pg_trgm;
CREATE EXTENSION btree_gin;
CREATE EXTENSION citext;
CREATE EXTENSION pgstattuple;
CREATE EXTENSION pg_buffercache;
-- Optional: pgvector if AI, postgis if geo, timescaledb if TS
Cập nhật: 2026-05-16. Postgres ecosystem rich — invest in knowing it.