21.05.2014 Views

Performance Comparison of Postgres 8.4 Vs Postgres 8.3 - PGCon

Performance Comparison of Postgres 8.4 Vs Postgres 8.3 - PGCon

Performance Comparison of Postgres 8.4 Vs Postgres 8.3 - PGCon

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Performance</strong> <strong>Comparison</strong><br />

<strong>of</strong> <strong>Postgres</strong> <strong>8.4</strong><br />

<strong>Vs</strong> <strong>Postgres</strong> <strong>8.3</strong><br />

Jignesh Shah<br />

Staff Engineer,<br />

ISV Engineering,<br />

Sun Microsystems Inc<br />

<strong>PGCon</strong> 2009


About Me<br />

• Working with Sun Microsystems for about 8 1/2 years<br />

> All <strong>of</strong> them in ISV Engineering (MDE)<br />

> Primarily responsibility at Sun is to make ISV and<br />

Open Source Community S<strong>of</strong>tware applications run<br />

best on Sun<br />

• Worked with various databases (<strong>Postgres</strong>, MySQL, DB2<br />

UDB, Progress OpenEdge, Oracle)<br />

• Prior to Sun worked as ERP Consultant<br />

• Worked with various ERP (QAD, Lawson) and CRM<br />

(Dispatch-1), etc<br />

• Previous responsibilities also included : Low Cost Data<br />

Warehousing<br />

• Blog: http://blogs.sun.com/jkshah<br />

<strong>PGCon</strong> 2009: Jignesh Shah 2


Goal / Agenda<br />

• Goal: Regression test <strong>of</strong> <strong>8.4</strong> <strong>Vs</strong> <strong>8.3</strong><br />

• <strong>Performance</strong> Changes in <strong>Postgres</strong> <strong>8.4</strong><br />

• Test Setup<br />

• Benchmarks<br />

• Summary<br />

<strong>PGCon</strong> 2009: Jignesh Shah 3


<strong>Performance</strong> Changes<br />

in <strong>Postgres</strong> <strong>8.4</strong><br />

<strong>PGCon</strong> 2009: Jignesh Shah 4


<strong>Postgres</strong> <strong>8.4</strong> Changes<br />

• Feature release<br />

• Not a performance release but<br />

> Has features which may impact performance<br />

• New Free Space Map Implementation<br />

> Gets rid <strong>of</strong> max_fsm_pages & max_fsm_relations<br />

• New Visibility Maps<br />

> Tracks changed tuples from last VACUUM<br />

> Improves VACUUM <strong>Performance</strong><br />

• Multi process restore with pg_restore -j option<br />

> Trick used : Remove constraints, load tables in parallel<br />

and then re-apply constraints<br />

<strong>PGCon</strong> 2009: Jignesh Shah 5


Other <strong>Postgres</strong> <strong>8.4</strong> Tweaks/Changes<br />

• And many other...<br />

> Constraint exclusion = 'partition' (it was “<strong>of</strong>f” in PG <strong>8.3</strong>)<br />

> default_statistics_target = 100 ( it was 10 in PG <strong>8.3</strong>)<br />

> New GUC stats_temp_directory<br />

> Enhanced Optimizer statistics calculations, full-text columns<br />

> New semi-join and anti-join executor methods<br />

> concurrent_io_reads for readaheads <strong>of</strong> bitmap index scans<br />

> Not supported on OpenSolaris<br />

> cursor_tuple_fraction<br />

> Hash index for DISTINCT/UNION/INTERSECT/EXCEPTION<br />

> Improvement in build speed for Hash index<br />

> Reduction in memory footprint for trigger handling<br />

> suppress_redundant_updates_trigger() added<br />

<strong>PGCon</strong> 2009: Jignesh Shah 6


Test Setup<br />

<strong>PGCon</strong> 2009: Jignesh Shah 7


Test Setup<br />

• Sun Fire X6270<br />

> 2x Quad Core Intel Xeon 5500 (Nehalem) Series<br />

> 8 Cores, 16 threads (with Hyperthreads ON)<br />

• OpenSolaris 2009.06 preview (build 111a)<br />

• Sun StorageTek 2540<br />

> 12 x 146 GB Drives (FC)<br />

• Workloads used:<br />

> Pgbench<br />

> Sysbench – OLTP ( read only & read write)<br />

> dbt2 with W 100<br />

> dbt3 with 5GB scale factor<br />

> iGen v1.6<br />

<strong>PGCon</strong> 2009: Jignesh Shah 8


Test Layout<br />

• PGDATA on 4-disk RAID0 ZFS<br />

• PGLOG on 4-disk RAID0 UFS (forcedirectio)<br />

• For each test<br />

> Database dropped, recreated, reloaded<br />

> Pretty much same procedures were used for both versions<br />

> Multiple runs were done to check that it wasn't a fluke<br />

<strong>PGCon</strong> 2009: Jignesh Shah 9


Benchmark<br />

<strong>Comparison</strong>s<br />

<strong>PGCon</strong> 2009: Jignesh Shah 10


PgBench (Select) <strong>Comparison</strong><br />

35000<br />

Database Scale <strong>of</strong> 100<br />

30000<br />

Transactions Per Second<br />

25000<br />

20000<br />

15000<br />

10000<br />

Tps<br />

(<strong>8.3</strong>.7) Tps<br />

(<strong>8.4</strong>Beta1)<br />

2%<br />

5000<br />

0<br />

0 4 8 12 16 20 24 28 32<br />

Number <strong>of</strong> active Clients<br />

• Using pgbench tools from Greg Smith (very helpful)<br />

• Carried over for various DB Scale<br />

13X<br />

<strong>PGCon</strong> 2009: Jignesh Shah 11


Sysbench OLTP RO <strong>Comparison</strong><br />

7000<br />

Sysbench OLTP Read-Only<br />

6000<br />

Transactions Per Second<br />

5000<br />

4000<br />

3000<br />

2000<br />

TPS(<strong>8.3</strong>.7)<br />

TPS(<strong>8.4</strong>Beta1)<br />

-2%<br />

1000<br />

7X<br />

0<br />

0 4 8 12 16 20 24 28 32<br />

Number <strong>of</strong> Clients<br />

<strong>PGCon</strong> 2009: Jignesh Shah 12


Sysbench -OLTP RW <strong>Comparison</strong><br />

4500<br />

Sysbench<br />

OLTP - Read Write<br />

Transactions Per Second<br />

4000<br />

3500<br />

3000<br />

2500<br />

2000<br />

1500<br />

1000<br />

500<br />

TPS (<strong>8.3</strong>.7)<br />

TPS(<strong>8.4</strong>beta1)<br />

0.4%<br />

8.5X<br />

0<br />

0 4 8 12 16 20 24 28 32<br />

Number <strong>of</strong> Concurrent Threads<br />

<strong>PGCon</strong> 2009: Jignesh Shah 13


iGen <strong>Comparison</strong><br />

350000<br />

iGen Transactions Per Minute<br />

<strong>8.3</strong> <strong>Vs</strong> <strong>8.4</strong> (with 0 think<br />

300000<br />

250000<br />

-5%<br />

Transactions Per Minute<br />

200000<br />

150000<br />

100000<br />

PG <strong>8.3</strong>.7<br />

PG <strong>8.4</strong>beta1<br />

50000<br />

0<br />

0 4 8 12 16 20 24 28 32 36 40 44 48<br />

Number <strong>of</strong> Simultaneous Active Clients<br />

<strong>PGCon</strong> 2009: Jignesh Shah 14


DBT-2 <strong>Comparison</strong> (First Set <strong>of</strong> tests)<br />

DBT-2<br />

W=100, no think time<br />

TPM(<strong>8.3</strong>.7)<br />

TPM(<strong>8.4</strong>beta1)<br />

-20%<br />

0 5000 10000 15000 20000 25000 30000 35000 40000 45000<br />

<strong>PGCon</strong> 2009: Jignesh Shah 15


DBT-2: Glitches Observed<br />

Tunable PG <strong>8.3</strong> PG <strong>8.4</strong>beta1 Comments<br />

default_statistics_target 10 100 Dbt2 like the value at 10<br />

constraints_exclude <strong>of</strong>f partition Dbt2 seems to like the value<br />

to <strong>of</strong>f<br />

With new defaults dbt2 take<br />

about 15-20% hit<br />

<strong>PGCon</strong> 2009: Jignesh Shah 16


DBT-2 <strong>Comparison</strong><br />

DBT-2<br />

W=100, no think time<br />

TPM(<strong>8.3</strong>.7)<br />

5%<br />

TPM(<strong>8.4</strong>beta1)<br />

0 5000 10000 15000 20000 25000 30000 35000 40000 45000 50000<br />

<strong>PGCon</strong> 2009: Jignesh Shah 17


Operation Step<br />

DBT-3 <strong>Comparison</strong><br />

Load<br />

1 Query Stream<br />

dbt-3<br />

(<strong>8.3</strong>.7 <strong>Vs</strong> <strong>8.4</strong>beta1)<br />

dbt3(<strong>8.3</strong>.7)<br />

dbt3(<strong>8.4</strong>beta1)<br />

4 Query Stream<br />

7%<br />

Total<br />

0<br />

200<br />

400<br />

600<br />

800<br />

1000<br />

1200<br />

Time in Seconds - Lower is better<br />

<strong>PGCon</strong> 2009: Jignesh Shah 18


<strong>8.3</strong> <strong>Vs</strong> <strong>8.4</strong> Summary Results<br />

Workload<br />

<strong>Performance</strong><br />

Gain/Loss in %<br />

PGBench 2.37<br />

Sysbench RO -2.17<br />

Sysbench RW 0.4<br />

IGEN V1.6 -4.50<br />

DBT-2 (W=100) 5.54*<br />

DBT-3 (SF=5) 6.83<br />

* default_statistics_target = 10<br />

constraints_exclude = <strong>of</strong>f<br />

<strong>PGCon</strong> 2009: Jignesh Shah 19


Results Interpretations<br />

• <strong>8.4</strong> <strong>Performance</strong> seems to be within<br />

+/- 5% for most workloads<br />

• Anything +/- 2% is potentially error margin<br />

in tests itself<br />

• Long running simultaneous queries may<br />

see improvements<br />

• Some workloads may be impacted by<br />

default_statistics_target and<br />

constraint_exclude<br />

<strong>PGCon</strong> 2009: Jignesh Shah 20


PostgreSQL Lock Waits<br />

by Workload<br />

-For Developers!<br />

<strong>PGCon</strong> 2009: Jignesh Shah 21


pglockwait_84.d Tool<br />

• Prints out a summary every 10 second<br />

• Can be used on single backend using<br />

$PID or all backends using '*'<br />

• Output is Lock Type, wait time for<br />

backends spent in wait state for locks and<br />

counts for waits<br />

• Useful to figure out how much time was<br />

wasted in wait states for acquiring locks<br />

<strong>PGCon</strong> 2009: Jignesh Shah 22


PGBench Select.sql- Hot Locks Waits<br />

Lock-Id Mode Wait-Time(ms) Count<br />

LockMgrLocks Exclusive 7006 94922<br />

• About 40 backends in this snapshot<br />

• LockMgrLocks are aggregated for all<br />

NUM_LOCK_PARTITIONS<br />

• Wait-times and Count to be taken with a<br />

grain <strong>of</strong> salt<br />

• Important data is top lock waits types<br />

<strong>PGCon</strong> 2009: Jignesh Shah 23


Sysbench RO- Hot Locks Waits<br />

Lock-Id Mode Wait-Time(ms) Count<br />

LockMgrLocks Exclusive 35 601<br />

<strong>PGCon</strong> 2009: Jignesh Shah 24


Sysbench RW- Hot Locks Waits<br />

Lock-Id Mode Wait-<br />

Time(ms)<br />

Count<br />

WALInsertLock Exclusive 105 9117<br />

LockMgrLocks Exclusive 72 5858<br />

ProcArrayLock Exclusive 50 1422<br />

DynamicLocks Shared 32 1767<br />

CLogControlLock Shared 17 1433<br />

ProcArrayLock Shared 11 912<br />

DynamicLocks Exclusive 8 388<br />

CLogControlLock Exclusive 2 234<br />

<strong>PGCon</strong> 2009: Jignesh Shah 25


Igen Hot Locks Waits Observed<br />

Lock-Id Mode Time(ms) Count<br />

LockMgrLocks Exclusive 53837 80247<br />

ProcArrayLock Exclusive 40130 89132<br />

WALInsertLock Exclusive 4895 26081<br />

ProcArrayLock Shared 1028 5360<br />

XidGenLock Exclusive 520 1394<br />

CLogControlLock Exclusive 60 1226<br />

CLogControlLock Shared 30 976<br />

BufMappingLocks Exclusive 7 14<br />

DynamicLocks Shared 1 11<br />

<strong>PGCon</strong> 2009: Jignesh Shah 26


DBT2 Hot Locks Waits Observed<br />

Lock-Id Mode Time(ms) Count<br />

BufMappingLocks Shared 8534 28207<br />

LockMgrLocks Exclusive 4186 11019<br />

BufMappingLocks Exclusive 1604 9213<br />

WALInsertLock Exclusive 1373 25942<br />

ProcArrayLock Exclusive 300 1246<br />

DynamicLocks Shared 163 597<br />

CLogControlLock Exclusive 136 759<br />

CLogControlLock Shared 52 991<br />

BufFreelistLock Exclusive 22 790<br />

DynamicLocks Exclusive 12 29<br />

ProcArrayLock Shared 4 263<br />

<strong>PGCon</strong> 2009: Jignesh Shah 27


Useful Dtrace Scripts<br />

• pgtps.d – Transactions Per Second<br />

• pglockwait_84.d – Lock Wait Statistics<br />

• PostgreSQL Dtrace Toolkit on pgfoundry<br />

> http://pgfoundry.org/projects/dtrace/<br />

• Available from http://blogs.sun.com/jkshah<br />

<strong>PGCon</strong> 2009: Jignesh Shah 28


Acknowledgements<br />

• Greg Smith – For pgbench tools<br />

• Mark Wong - DBT-2<br />

• Sun Microsystems Inc – Hardware, Time<br />

<strong>PGCon</strong> 2009: Jignesh Shah 29


Q & A<br />

• Blog: http://blogs.sun.com/jkshah<br />

<strong>PGCon</strong> 2009: Jignesh Shah 30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!