performance archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot...

47
Performance Archaeology Tomáš Vondra, GoodData [email protected] / [email protected] @fuzzycz, http://blog.pgaddict.com Photo by Jason Quinlan, Creative Commons CC-BY-NC-SA https://www.flickr.com/photos/catalhoyuk/9400568431

Upload: others

Post on 02-Oct-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Performance Archaeology

Tomáš Vondra, [email protected] / [email protected]

@fuzzycz, http://blog.pgaddict.com

Photo by Jason Quinlan, Creative Commons CC-BY-NC-SAhttps://www.flickr.com/photos/catalhoyuk/9400568431

Page 2: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

How did the PostgreSQL performance

evolve over the time?

7.4 released 2003, i.e. ~10 years

Page 3: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

(surprisingly) tricky question

● usually “partial” tests during development– compare two versions / commits

– focused on a particular part of the code / feature

● more complex benchmarks compare two versions– difficult to “combine” (different hardware, ...)

● application performance (ultimate benchmark)– apps are subject to (regulard) hardware upgrades

– amounts of data grow, applications evolve (new features)

Page 4: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

(somehow) unfair question

● we do develop within context of the current hardware– How much RAM did you use 10 years ago?

– Who of you had SSD/NVRAM drives 10 years ago?

– How common were machines with 8 cores?

● some differences are consequence of these changes● a lot of stuff was improved outside PostgreSQL (ext3 -> ext4)

Better performance on current

hardware is always nice ;-)

Page 5: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Let's do some benchmarks!

Page 6: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

short version:

We're much faster and more scalable.

Page 7: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

If you're scared of numbers or charts,

you should probably leave now.

Page 8: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

http://blog.pgaddict.com

http://planet.postgresql.org

http://slidesha.re/1CUv3xO

Page 9: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Benchmarks (overview)

● pgbench (TPC-B)– “transactional” benchmark

– operations work with small row sets (access through PKs, ...)

● TPC-DS (replaces TPC-H)– “warehouse” benchmark

– queries chewing large amounts of data (aggregations, joins, ROLLUP/CUBE, ...)

● fulltext benchmark (tsearch2)– primarily about improvements of GIN/GiST indexes

– now just fulltext, there are many other uses for GIN/GiST (geo, ...)

Page 10: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Hardware used

HP DL380 G5 (2007-2009)● 2x Xeon E5450 (each 4 cores @ 3GHz, 12MB cache)

● 16GB RAM (FB-DIMM DDR2 667 MHz), FSB 1333 MHz

● S3700 100GB (SSD)

● 6x10k RAID10 (SAS) @ P400 with 512MB write cache

● Scientific Linux 6.5 / kernel 2.6.32, ext4

Page 11: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

pgbench

TPC-B “transactional” benchmark

Page 12: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

pgbench

● three dataset sizes– small (150 MB)

– medium (~50% RAM)

– large (~200% RAM)

● two modes– read-only and read-write

● client counts (1, 2, 4, ..., 32)● 3 runs / 30 minute each (per combination)

Page 13: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

pgbench

● three dataset sizes– small (150 MB) <– locking issues, etc.

– medium (~50% RAM) <– CPU bound

– large (~200% RAM) <– I/O bound

● two modes– read-only and read-write

● client counts (1, 2, 4, ..., 32)● 3 runs / 30 minute each (per combination)

Page 14: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

BEGIN;

    UPDATE accounts SET abalance = abalance + :delta     WHERE aid = :aid;

    SELECT abalance FROM accounts WHERE aid = :aid;

    UPDATE tellers SET tbalance = tbalance + :delta     WHERE tid = :tid;

    UPDATE branches SET bbalance = bbalance + :delta     WHERE bid = :bid;

    INSERT INTO history (tid, bid, aid, delta, mtime)    VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);

END;

Page 15: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

2000

4000

6000

8000

10000

12000

pgbench / large read-only (on SSD)

HP DL380 G5 (2x Xeon E5450, 16 GB DDR2 RAM), Intel S3700 100GB SSD

7.4 8.0 8.1 head

number of clients

tran

sact

ion

s p

er s

econ

d

Page 16: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

10000

20000

30000

40000

50000

60000

70000

80000

pgbench / medium read-only (SSD)

HP DL380 G5 (2x Xeon E5450, 16 GB DDR2 RAM), Intel S3700 100GB SSD

7.4 8.0 8.1 8.2 8.3 9.0 9.2

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 17: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

500

1000

1500

2000

2500

3000

pgbench / large read-write (SSD)

HP DL380 G5 (2x Xeon E5450, 16 GB DDR2 RAM), Intel S3700 100GB SSD

7.4 8.1 8.3 9.1 9.2

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 18: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

1000

2000

3000

4000

5000

6000

pgbench / small read-write (SSD)

HP DL380 G5 (2x Xeon E5450, 16 GB DDR2 RAM), Intel S3700 100GB SSD

7.4 8.0 8.1 8.2 8.3 8.4 9.0 9.2

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 19: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

What about rotational drives?

6 x 10k SAS drives (RAID 10)

P400 with 512MB write cache

Page 20: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 300

100

200

300

400

500

600

700

800

pgbench / large read-write (SAS)

HP DL380 G5 (2x Xeon E5450, 16 GB DDR2 RAM), 6x 10k SAS RAID10

7.4 (sas) 8.4 (sas) 9.4 (sas)

number of clients

tra

nsa

ctio

n p

er

seco

nd

Page 21: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

What about a different machine?

Page 22: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Alternative hardware

Workstation i5 (2011-2013)● 1x i5-2500k (4 cores @ 3.3 GHz, 6MB cache)

● 8GB RAM (DIMM DDR3 1333 MHz)

● S3700 100GB (SSD)

● Gentoo, kernel 3.12, ext4

Page 23: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

5000

10000

15000

20000

25000

30000

35000

40000

pgbench / large read-only (Xeon vs. i5)

2x Xeon E5450 (3GHz), 16 GB DDR2 RAM, Intel S3700 100GB SSDi5-2500k (3.3 GHz), 8GB DDR3 RAM, Intel S3700 100GB SSD

7.4 (Xeon) 9.0 (Xeon) 7.4 (i5) 9.0 (i5)

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 24: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

20000

40000

60000

80000

100000

pgbench / small read-only (Xeon vs. i5)

2x Xeon E5450 (3GHz), 16 GB DDR2 RAM, Intel S3700 100GB SSDi5-2500k (3.3 GHz), 8GB DDR3 RAM, Intel S3700 100GB SSD

7.4 (Xeon) 9.0 (Xeon) 9.4 (Xeon)7.4 (i5) 9.0 (i5) 9.4 (i5)

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 25: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

1000

2000

3000

4000

5000

6000

7000

8000

pgbench / small read-write (Xeon vs. i5)

2x Xeon E5450 (3GHz), 16 GB DDR2 RAM, Intel S3700 100GB SSDi5-2500k (3.3 GHz), 8GB DDR3 RAM, Intel S3700 100GB SSD

7.4 (Xeon) 9.4 (Xeon) 7.4 (i5) 9.4b1 (i5)

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 26: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Legends say older version

work better with lower memory limits

(shared_buffers etc.)

Page 27: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0 5 10 15 20 25 30 350

5000

10000

15000

20000

25000

30000

35000

40000

pgbench / large read-only (i5-2500)

different sizes of shared_buffers (128MB vs. 2GB)

7.4 7.4 (small) 8.08.0 (small) 9.4b1

number of clients

tra

nsa

ctio

ns

pe

r se

con

d

Page 28: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

pgbench / summary

● much better● improved locking

– much better scalability to a lot of cores (>= 64)

● a lot of different optimizations– significant improvements even for small client counts

● lessons learned– CPU frequency is very poor measure

– similarly for number of cores etc.

Page 29: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

TPC-DS

“Decision Support” benchmark

(aka “Data Warehouse” benchmark)

Page 30: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

TPC-DS

● analytics workloads / warehousing– queries processing large data sets (GROUP BY, JOIN)

– non-uniform distribution (more realistic than TPC-H)

● 99 query templates defined (TPC-H just 22)– some broken (failing generator)

– some unsupported (e.g. ROLLUP/CUBE)

– 41 queries >= 7.4

– 61 queries >= 8.4 (CTE, Window functions)

– no query rewrites

Page 31: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

TPC-DS

● 1GB and 16GB datasets (raw data)– 1GB insufficient for publication, 16GB nonstandard (according to TPC)

● interesting anyways ...– a lot of databases fit into 16GB

– shows trends (applicable to large DBs)

● schema– pretty much default (standard compliance FTW!)

– same for all versions (indexes K/join keys, a few more indexes)

– definitely room for improvements (per version, ...)

Page 32: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.4 head0

1000

2000

3000

4000

5000

6000

7000

TPC DS / database size per 1GB raw data

data indexes

size

[M

B]

Page 33: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.4 head0

200

400

600

800

1000

1200

1400

TPC DS / load duration (1GB)

copy indexes vacuum full vacuum freeze analyze

du

ratio

n [

s]

Page 34: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.4 head0

200

400

600

800

1000

1200

TPC DS / load duration (1GB)

copy indexes vacuum freeze analyze

du

ratio

n [

s]

Page 35: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.40

1000

2000

3000

4000

5000

6000

7000

8000

9000

TPC DS / load duration (16 GB)

LOAD INDEXES VACUUM FREEZE ANALYZE

du

ratio

n [

seco

nd

s]

Page 36: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.4 head

0

50

100

150

200

250

300

350

TPC DS / duration (1GB)

average duration of 41 queries

seco

nd

s

Page 37: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0* 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.40

1000

2000

3000

4000

5000

6000

TPC DS / duration (16 GB)

average duration of 41 queries

version

du

ratio

n [

seco

nd

s]

Page 38: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

TPC-DS / summary

● data load much faster– most of the time spent on indexes (parallelize, RAM)

– ignoring VACUUM FULL (different implementation 9.0)

– slightly less space occupied

● much faster queries– in total the speedup is ~6x

– wider index usage, index only scans

Page 39: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Fulltext Benchmark

testing GIN and GiST indexesthrough fulltext search

Page 40: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Fulltext benchmark

● searching through pgsql mailing list archives– ~1M messages, ~5GB of data

● ~33k real-world queries (from postgresql.org)– syntetic queries lead to about the same results

SELECT id FROM messages

WHERE body @@ ('high & performance')::tsquery

ORDER BY ts_rank(body, ('high & performance')::tsquery)

DESC LIMIT 100;

Page 41: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0200400600800

100012001400160018002000

Fulltext benchmark / load

COPY / with indexes and PL/pgSQL triggers

COPY VACUUM FREEZE ANALYZE

du

ratio

n [

sec]

Page 42: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.4

0

1000

2000

3000

4000

5000

6000

Fulltext benchmark / GiST

33k queries from postgresql.org [TOP 100]

tota

l ru

ntim

e [

sec]

Page 43: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.4

0

100

200

300

400

500

600

700

800

Fulltext benchmark / GIN

33k queries from postgresql.org [TOP 100]

tota

l ru

ntim

e [s

ec]

Page 44: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 9.40

1000

2000

3000

4000

5000

6000

Fulltext benchmark - GiST vs. GIN

33k queries from postgresql.org [TOP 100]

GiST GIN

tota

l du

ratio

n [

sec]

Page 45: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

0.1 1 10 100 10000

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

Fulltext benchmark / 9.3 vs. 9.4 (GIN fastscan)

9.4 durations, divided by 9.3 durations (e.g. 0.1 means 10x speedup)

duration on 9.3 [miliseconds, log scale]

9.4

du

ratio

n (

rela

tive

to

9.3

)

Page 46: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

Fulltext / summary

● GIN fastscan– queries combining “frequent & rare”

– 9.4 scans “frequent” posting lists first

– exponential speedup for such queries

– ... which is quite nice ;-)

● only ~5% queries slowed down– mostly queries below 1ms (measurement error)

Page 47: Performance Archaeology - wiki.postgresql.orgmore complex benchmarks compare two versions ... a lot of stuff was improved outside PostgreSQL (ext3 -> ext4) Better performance on current

http://blog.pgaddict.com

http://planet.postgresql.org

http://slidesha.re/1CUv3xO