
2
Contents
Introduction 3
Parameters 4
• PostgreSQL Parameters: Scope and Priority Users Should Know �����������������������������������������������������������������������������������������������������������������������������������5
• It’s All About Replication Lag in PostgreSQL ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� 13
• Optimizing Database Parameters for Maximum Efciency ������������������������������������������������������������������������������������������������������������������������������������������������ 16
Query optimization 21
• Query Optimization with Python and PgBouncer �������������������������������������������������������������������������������������������������������������������������������������������������������������������������22
• Improve PostgreSQL Query Performance Insights with pg_stat_monitor ���������������������������������������������������������������������������������������������������������28
Monitoring 32
• PostgreSQL Checkpoints, Buffers, and WAL Usage with Percona Monitoring and Management ������������������������������������������������ 33
• Understand Your PostgreSQL Workloads Better with pg_stat_monitor ��������������������������������������������������������������������������������������������������������������� 40
• Monitoring PostgreSQL Databases Using PMM ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ 45
Indexing 54
• PostgreSQL Indexes Can Hurt You: Negative Effects and the Costs Involved �������������������������������������������������������������������������������������������������� 55
• Useful Queries For PostgreSQL Index Maintenance ������������������������������������������������������������������������������������������������������������������������������������������������������������������� 59
Vaccuming 64
• PostgreSQL Vacuuming Command to Optimize Database Performance ������������������������������������������������������������������������� 65
• Why Custom Scheduled Jobs for Vacuuming and Fine-grained Autovacuum Tuning Are Unavoidable ��������������������73
• Overcoming VACUUM WRAPAROUND �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������78
Partitioning 84
• PostgreSQL Partitioning Using Traditional Methods ������������������������������������������������������������������������������������������������������������������������������������������������������������������ 85
• Partitioning in PostgreSQL With pg_partman (Serial-Based & Trigger-Based) ������������������������������������������������������������������������������������������� 94
Schema design 100
• Difng PostgreSQL Schema Changes ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������101
Load balancing/connection pooling 105
• Pgpool-II Use Cases and Benets ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������106
• Scaling PostgreSQL using Connection Poolers and Load Balancers for an Enterprise Grade environment ����������������� 108
PostGIS 112
• Using PostGIS To Enable Better Performance in PostgreSQL ���������������������������������������������������������������������������������������������������������������������������������������������113
Bonus: Cost optimization 121
• Reducing PostgreSQL Costs in the Cloud �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������122
Conclusion 129
评论