Core Extensions for postgresql Performance Tuning
Core Extensions for postgresql Performance Tuning
1. pg_stat_statements
o Purpose: Tracks execution statistics of queries.
o Usage: Identifies slow or frequently executed queries for optimization.
o Setup: Add to shared_preload_libraries.
2. pg_stat_kcache
o Purpose: Provides OS-level statistics (e.g., CPU and I/O usage) for queries.
o Usage: Offers deeper insights into resource consumption.
o Setup: Requires pg_stat_statements to be enabled.
3. pg_wait_sampling
o Purpose: Samples wait events to identify database bottlenecks.
o Usage: Useful for diagnosing lock contention, I/O waits, and more.
o Setup: Add to shared_preload_libraries.
4. auto_explain
o Purpose: Automatically logs execution plans for slow queries.
o Usage: Diagnoses query planning issues for performance optimization.
o Setup: Configured in postgre.conf.
5. hypopg
o Purpose: Allows the creation of hypothetical indexes to evaluate their impact
without actually creating them.
o Usage: Index tuning and optimization.
o Setup:
Example usage:
Internal
SELECT * FROM hypopg_create_index('CREATE INDEX ON my_table (my_column)');
6. pg_buffercache
o Purpose: Displays the contents of the shared buffer pool.
o Usage: Identifies how much of your data resides in memory vs. disk.
o Setup:
Query example:
7. pg_cron
o Purpose: Schedules periodic tasks like VACUUM or ANALYZE.
o Usage: Automates maintenance tasks.
8. pg_repack
o Purpose: Reorganizes tables and indexes to remove bloat without locking them.
o Usage: Reduces table and index bloat while maintaining availability.
9. plpg_check
o Purpose: Performs static analysis of PL/pg functions.
o Usage: Identifies inefficiencies and errors in stored procedures.
10. pg_sentinel
o Purpose: Provides session-level statistics.
o Usage: Tracks session activity and transaction details for analysis.
Internal
Advanced Optimization Extensions
11. pg_hint_plan
o Purpose: Allows users to add hints to queries to influence the query planner.
o Usage: Optimizes complex queries where the default planner may choose
suboptimal plans.
12. pg_stat_plans
o Purpose: Captures and analyzes query execution plans over time.
o Usage: Identifies query plan changes that impact performance.
13. pg_stat_io
o Purpose: Tracks I/O usage at the query and table level.
o Usage: Analyzes I/O bottlenecks in the system.
14. pg_bigm
o Purpose: Enables fast full-text search with bigram indexing.
o Usage: Speeds up text search operations.
15. pg_prewarm
o Purpose: Preloads tables or indexes into memory at startup or on demand.
o Usage: Improves performance for frequently accessed data.
16. timescaledb
o Purpose: Optimizes Postgre for time-series data.
o Usage: Enhances performance for time-series workloads.
Internal
CREATE EXTENSION timescaledb;
Extensions Summary
Internal