PGCon 2011. PostgreSQL Performance Pitfalls

Similar documents
PostgreSQL 9.0 High Performance

PostgreSQL when it s not your job. Christophe Pettus PostgreSQL Experts, Inc. DjangoCon Europe 2012

PostgreSQL when it s not your job. Christophe Pettus PostgreSQL Experts, Inc. DjangoCon US 2012

Check Please! What your Postgres database wishes you would monitor. / Presentation

Monitor the Heck Out Of Your Database

Configuring Apache Derby for Performance and Durability Olav Sandstå

Administering your PostgreSQL Geodatabase

PostgreSQL Performance when it s not your job.

Keep an eye on your PostgreSQL clusters

High Performance Odoo

PostgreSQL extension s development

How To Run A Standby On Postgres (Postgres) On A Slave Server On A Standby Server On Your Computer (Mysql) On Your Server (Myscientific) (Mysberry) (

Oracle Database 11 g Performance Tuning. Recipes. Sam R. Alapati Darl Kuhn Bill Padfield. Apress*

The Future of PostgreSQL High Availability Robert Hodges - Continuent, Inc. Simon Riggs - 2ndQuadrant

PostgreSQL 9.0 Streaming Replication under the hood Heikki Linnakangas

Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3

SAP HANA PLATFORM Top Ten Questions for Choosing In-Memory Databases. Start Here

Be Very Afraid. Christophe Pettus PostgreSQL Experts Logical Decoding & Backup Conference Europe 2014

Audit & Tune Deliverables

What is new in Switch 12

Postgres Plus Advanced Server

Lotus Domino Backup Strategy

Monitoring PostgreSQL database with Verax NMS

PostgreSQL Backup Strategies

Which Database is Better for Zabbix? PostgreSQL vs MySQL. Yoshiharu Mori SRA OSS Inc. Japan

Outline. Failure Types

Agenda Hi-Media Activities Tool Set for production Replication and failover Conclusion. 2 years of Londiste. Dimitri Fontaine.

Database Hardware Selection Guidelines

Workflow Templates Library

PostgreSQL 9.4 up and running.. Vasilis Ventirozos Database Administrator OmniTI

PostgreSQL Past, Present, and Future EDB All rights reserved.

Tushar Joshi Turtle Networks Ltd

Configuring Apache Derby for Performance and Durability Olav Sandstå

MySQL Storage Engines

Agenda. Enterprise Application Performance Factors. Current form of Enterprise Applications. Factors to Application Performance.

WHMCS WHMCS Author: Version: Date:

Managing your Domino Clusters

In and Out of the PostgreSQL Shared Buffer Cache

Sawmill Log Analyzer Best Practices!! Page 1 of 6. Sawmill Log Analyzer Best Practices

Optimising the Mapnik Rendering Toolchain

Scaling Graphite Installations

Integrated Monitoring for PostgreSQL

Boost SQL Server Performance Buffer Pool Extensions & Delayed Durability

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Monitoring MySQL. Kristian Köhntopp

University of Edinburgh. Performance audit. Date: Niels van Klaveren Kasper van der Leeden Yvette Vermeer

Improve Business Productivity and User Experience with a SanDisk Powered SQL Server 2014 In-Memory OLTP Database

General DBA Best Practices

Geospatial Server Performance Colin Bertram UK User Group Meeting 23-Sep-2014

Optimizing Performance. Training Division New Delhi

Benchmarking FreeBSD. Ivan Voras

Eloquence Training What s new in Eloquence B.08.00

Application Brief: Using Titan for MS SQL

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

Client Hardware and Infrastructure Suggested Best Practices

This document will list the ManageEngine Applications Manager best practices

WITH A FUSION POWERED SQL SERVER 2014 IN-MEMORY OLTP DATABASE

MS SQL Performance (Tuning) Best Practices:

Practical Cassandra. Vitalii

Gleb Arshinov, Alexander Dymo PGCon 2010 PostgreSQL as a secret weapon for high-performance Ruby on Rails applications

Dave Stokes MySQL Community Manager

$99.95 per user. SQL Server 2008/R2 Database Administration CourseId: 157 Skill level: Run Time: 47+ hours (272 videos)

Mind Q Systems Private Limited

Spatialite-gui. a GUI tool to manage SQLite and SpatiaLite databases. Just few very short notes showing How to get started as quick as possible

OLTP Meets Bigdata, Challenges, Options, and Future Saibabu Devabhaktuni

Stellar Phoenix. SQL Database Repair 6.0. Installation Guide

SQL Server 2012 Database Administration With AlwaysOn & Clustering Techniques

Google File System. Web and scalability

news from Tom Bacon about Monday's lecture

Diskeeper Can Boost Your SQL Server's Performance

Secure Web. Hardware Sizing Guide

How To Support A Backup At Cornell

Microsoft SQL Database Administrator Certification

Office 365 Migration Performance & Server Requirements

DBA 101: Best Practices All DBAs Should Follow

MapGuide Open Source Repository Management Back up, restore, and recover your resource repository.

Symantec Backup Exec 2014 Icon List

Oracle DBA Course Contents

Maintaining Non-Stop Services with Multi Layer Monitoring

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

TUTORIAL WHITE PAPER. Application Performance Management. Investigating Oracle Wait Events With VERITAS Instance Watch

SCF/FEF Evaluation of Nagios and Zabbix Monitoring Systems. Ed Simmonds and Jason Harrington 7/20/2009

Microsoft SQL Server OLTP Best Practice

DBA Tutorial Kai Voigt Senior MySQL Instructor Sun Microsystems Santa Clara, April 12, 2010

Techniques for implementing & running robust and reliable DB-centric Grid Applications

Optimizing Your Database Performance the Easy Way

PostgreSQL database performance optimization. Qiang Wang

Data Compression in Blackbaud CRM Databases

Managing MySQL Scale Through Consolidation

Why Not Oracle Standard Edition? A Dbvisit White Paper By Anton Els

Enterprise Manager Performance Tips

DELL TM PowerEdge TM T Mailbox Resiliency Exchange 2010 Storage Solution

OS Thread Monitoring for DB2 Server

Products for the registry databases and preparation for the disaster recovery

#9011 GeoMedia WebMap Performance Analysis and Tuning (a quick guide to improving system performance)

How To Test For Speed On Postgres (Postgres) On A Microsoft Powerbook On A 2.2 Computer (For Microsoft) On An 8Gb Hard Drive (For

Best Practices Every SQL Server DBA Must Know

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

Transcription:

PGCon 2011 PostgreSQL Performance Pitfalls

Too much information PostgreSQL has a FAQ, manual, other books, a wiki, and mailing list archives RTFM? The 9.0 manual is 2435 pages You didn't do that

PostgreSQL Version Policy 8.3 8.4: Major version upgrade 8.4.3 8.4.4: Minor version upgrade No feature changes Bug fixes only Can involve database corruption Backports: more risky to not have the change Other vendors might say: Fix pack Service pack Hot fix Stay as current as possible

Starting Version Major changes in PostgreSQL 8.3 Upgrades from earlier ones very painful In-place upgrades become possible Performance is much better in 8.3 New projects shouldn't consider anything earlier Your operating system packages are not better Same packagers involved in many cases

Default configuration Optimized for startup with low shared memory Many parameters too low for your phone! Need to adjust several memory related items http://wiki.postgresql.org/wiki/tuning_your_postgresql_server pgtune

Major parameters to set shared_buffers: 512MB to 8GB checkpoint_segments: 16 to 256 effective_cache_size: typically ¾ of RAM work_mem: memory / connections / (4 to 32)

Bad table statistics Why didn't it use my index? Sequential scans can be faster Might be statistics issues however Check data from EXPLAIN ANALYZE Look for variation between estimated vs. actual Manual ANALYZE doesn't take very long May also have to increase statistics target Can be done on a single column

Statistics adjustment default_statistics_target is 100 in >=8.4 100 1000 is useful range ALTER TABLE t COLUMN c SET STATISTICS n; Check analyze dates in pg_stat_user_tables Study pg_stats, learn about MCVs and histograms

VACUUM Cleans up after UPDATE and DELETE Autovacuum updates database statistics Also considers INSERT quantity Large tables: 20% change required Intensive when it happens Must happen eventually for frozen ID cleanup Focus on smoothing and scheduling, not delay Dead rows add overhead you just don't see Table bloat can be very large

VACUUM monitoring Watch timestamps in pg_stat_user_tables Beware long-running transactions log_autovacuum_min_duration Sizes of tables/indexes critical too http://wiki.postgresql.org/wiki/disk_usage

Index Bloating Indexes can become less efficient after deletes VACUUM FULL before 9.0 makes this worse REINDEX helps, but locks too CREATE INDEX can run CONCURRENTLY Rename to simulate REINDEX CONCURRENTLY CLUSTER does a full table rebuild Same fresh performance as after dump/reload Full table lock to do it

Extensions and contrib Ship with the server Not installed by default Extensions are easy to install starting in 9.1 May need postgresql-contrib package Many useful ones in earlier versions too Just hard to install Page/index inspection tools

Useful extensions pageinspect pgstattuple pg_freespacemap pgrowlocks pg_stat_statements (8.4) auto_explain (8.4) pg_archivecleanup (9.0) pgcrypto dblink hstore

External tools You need them The PostgreSQL core is just that Many essential add-on tools

Monitoring Can use OS tools for simple monitoring You also want to monitor database stats pg_stat_user_tables most essential Helpful to track table/index sizes too Best tools combine OS data with database Munin, Cacti

OS Monitoring top -c vmstat 1 iostat -mx 5 htop iotop watch

Incident capture top -c -b nohup script

Table/Index Sizes SELECT nspname,relname, pg_size_pretty(pg_relation_size(c.oid)) AS "size", pg_size_pretty(pg_total_relation_size(c.oid)) AS "total_size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') ORDER BY pg_relation_size(c.oid) DESC; More at http://wiki.postgresql.org/wiki/disk_usage

Locking Need to combine pg_locks + pg_stat_activity Example queries: http://wiki.postgresql.org/wiki/lock_monitoring Surprising lock acquisition type and order

Database Monitoring top -c pg_stat_activity pg_locks pg_top

Alerting Out of disk space? Server will crash. pg_xlog WAL data should be small Often very small filesystem, easy to fill Critical on standby servers too Watch size of backup archive check_postgres for Nagios, others

Trends matter

Munin: Load average

Munin: CPU usage

Munin: Disk Util %

Connection Distribution

Database shared_buffers

Workload distribution

Long queries/transactions

Query Log Analysis Collect log data log_min_duration_statement Auto-explain Built-in pg_stat_statements Analyze logs with external tool pgfouine

pgfouine

Defensive, preemptive logging log_line_prefix = '%t [%p]: [%l 1] user= %u,db=%d ' log_min_duration_statement = 1000 log_temp_files = 0 log_checkpoints = on log_connections = on log_lock_waits = on log_autovacuum_min_duration = 1000

Connection Pooling Connections are expensive >500 at once will never work well Windows dies at ~125 Swapping between many processes is slow Optimal connections ~2-3X core count Use a connection pooler to limit connections pgbouncer, pgpool-ii, application server

Resource limits Memory limits aren't just a work_mem issue Tough to balance across the server No way to limit one query in the short term statement_timeout Use nice, ionice; more at http://wiki.postgresql.org/wiki/priorities

Replication surprises Built-in replication is not statement based Whole cluster only, not per-database Read-only queries can be send to standby But they can be canceled Better features here in 9.1

Low level issues Log checkpoints to catch spikes Watch lock waits Constraint and foreign key overhead Overindexing Linux Out-of-memory killer Battery-backed write cache for fast commits Beware volatile write caches

Questions?

PostgreSQL Books http://www.2ndquadrant.com/books/

2ndQuadrant Training Available now in UK, Italy, Germany Coming this fall to the US Includes hands-on workshops with instructor interaction Database administration Performance Replication and Recovery Real-world experience from production DBAs