15
i. Understand your application workload ii. Choose the right hardware iii. Select proper file system iv. Benchmark your environment v. Tune your Postgres Server vi. Perform Log Auditing vii. Understand your query plan viii.Tune your queries ix. Implement proper indexing x. Run / Schedule Maintenance jobs Top 10 Tips for Database Optimization

Top 10 database optimization tips

Embed Size (px)

Citation preview

i. Understand your application workloadii. Choose the right hardwareiii. Select proper file systemiv. Benchmark your environmentv. Tune your Postgres Server vi. Perform Log Auditingvii. Understand your query planviii. Tune your queriesix. Implement proper indexingx. Run / Schedule Maintenance jobs

Top 10 Tips for Database Optimization

TIP 1Understand Your Application Workload

How your application is interacting with your database.

Is your application read intensive or write intensive

ETL jobs.

Reporting and Analytical queries

CPUWhich Processor Family?More Cores Vs Faster Cores.

RAMIt depends on Size of working data set.

I/ODisk and Disk bandwidth.

NetworkLag time / Bandwidth

TIP 2Choose the Right Hardware

Pg_buffercache

What is your storage stagey?

SATA VS SCSI

DAS VS SAN

RAID POLICY

RAID CONTROLLER SETTINGS

Monitor o/p of iostat

Distribute DB objects across Tablespaces

Maintain Separate Disk for pg_xlog

Storage

Journaling file systems. Ext3 Ext4 Xfs

TIP 3Select proper File System

TIP 4Benchmark Your Environment

CPU: PassMark, Sysbench

RAM: memtest, cachebench

I/O: bonnie++, dd

Network: bwping, netperf

DB: pgBench, Sysbench

Hardware and Database Tests:

max_connections shared_buffers Effective_cache_size Work_mem Maintenance_work_mem

TIP 5Tune Your PostgreSQL Server

Experiment with Best Values

TIP 6Perform Log AuditingEnable slow running queries in PostgreSQL :

Log_min_duration_statement

Pg_stat_statements

Pgbadger,EPOA

Auto-explain

TIP 7 Understand your Query Plan

EXPLAIN Command

Scan Methods

Join Methods

Query Plan

TIP 8Tune your queries

Performance Tips

Indexes

WHERE clause

JOINs

TIP 9Implement Proper Indexing

Indexes

Partial Indexes

Expression Indexes

Unique Indexes

Multi-column Indexes

Managing / Maintaining Indexes

Unused Indexes and Index bloat

TIP 10Run / Schedule Maintenance Jobs

PostgreSQL Vacuum & Analyze

Maintenance & Performance