Top Banner
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
15

Top 10 database optimization tips

Apr 14, 2017

Download

Technology

raviwriter
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Top 10 database optimization tips

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

Page 2: Top 10 database optimization tips

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

Page 3: Top 10 database optimization tips

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

Page 4: Top 10 database optimization tips

Pg_buffercache

Page 5: Top 10 database optimization tips

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

Page 6: Top 10 database optimization tips

Journaling file systems. Ext3 Ext4 Xfs

TIP 3Select proper File System

Page 7: Top 10 database optimization tips

TIP 4Benchmark Your Environment

CPU: PassMark, Sysbench

RAM: memtest, cachebench

I/O: bonnie++, dd

Network: bwping, netperf

DB: pgBench, Sysbench

Hardware and Database Tests:

Page 8: Top 10 database optimization tips

max_connections shared_buffers Effective_cache_size Work_mem Maintenance_work_mem

TIP 5Tune Your PostgreSQL Server

Experiment with Best Values

Page 9: Top 10 database optimization tips

TIP 6Perform Log AuditingEnable slow running queries in PostgreSQL :

Log_min_duration_statement

Pg_stat_statements

Pgbadger,EPOA

Auto-explain

Page 10: Top 10 database optimization tips
Page 11: Top 10 database optimization tips

TIP 7 Understand your Query Plan

EXPLAIN Command

Scan Methods

Join Methods

Page 12: Top 10 database optimization tips

Query Plan

Page 13: Top 10 database optimization tips

TIP 8Tune your queries

Performance Tips

Indexes

WHERE clause

JOINs

Page 14: Top 10 database optimization tips

TIP 9Implement Proper Indexing

Indexes

Partial Indexes

Expression Indexes

Unique Indexes

Multi-column Indexes

Managing / Maintaining Indexes

Unused Indexes and Index bloat

Page 15: Top 10 database optimization tips

TIP 10Run / Schedule Maintenance Jobs

PostgreSQL Vacuum & Analyze

Maintenance & Performance