SlideShare una empresa de Scribd logo
1 de 43
Introduction to pgbench

         Greg Smith

             Truviso


        04/05/2009




     Greg Smith   Introduction to pgbench
About this presentation




      The master source for these slides is
      http://www.westnet.com/~gsmith/content/postgresql


      Slides are released under the Creative Commons Attribution
      3.0 United States License
      See http://creativecommons.org/licenses/by/3.0/us




                          Greg Smith   Introduction to pgbench
pgbench History



      TPC-B: http://www.tpc.org/tpcb/
      State of the art...in 1990
      Models a bank with accounts, tellers, and branches
      pgbench actually derived from JDBCbench
      http:
      //developer.mimer.com/features/feature_16.htm
      But aimed to eliminate Java overhead
      The JDBCbench code is buggy
      Early pgbench versions inherited some of those bugs




                          Greg Smith   Introduction to pgbench
Database scale



      Each scale increment adds another branch to the database
      1 branch + 10 tellers + 100000 accounts
      Total database size is approximately 16MB * scale


   createdb pgbench
   pgbench -i -s 10

      scale=10 makes for a 160MB database




                         Greg Smith   Introduction to pgbench
Database schema


  CREATE TABLE branches(bid int not null,
    bbalance int, filler char(88));
  ALTER TABLE branches add primary key (bid);
  CREATE TABLE tellers(tid int not null,bid int,
    tbalance int,filler char(84));
  ALTER TABLE tellers add primary key (tid);
  CREATE TABLE accounts(aid int not null,bid int,
    abalance int,filler char(84));
  ALTER TABLE accounts add primary key (aid);
  CREATE TABLE history(tid int,bid int,aid int,delta int,
    mtime timestamp,filler char(22));

                     Greg Smith   Introduction to pgbench
Filler




         Filler itended to make each row at least 100 bytes long
         Fail: null data inserted into it doesn’t do that
         Rows are therefore very narrow
         Not fixed because it would put new pgbench results on a
         different scale




                              Greg Smith   Introduction to pgbench
Scripting language




   set nbranches :scale
   set ntellers 10 * :scale
   set naccounts 100000 * :scale
   setrandom aid 1 :naccounts
   setrandom bid 1 :nbranches
   setrandom tid 1 :ntellers
   setrandom delta -5000 5000




                      Greg Smith   Introduction to pgbench
Standard test


   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;

                         Greg Smith   Introduction to pgbench
No teller/branch test




   BEGIN;
   UPDATE accounts SET abalance = abalance + :delta
     WHERE aid = :aid;
   SELECT abalance FROM accounts WHERE aid = :aid;
   INSERT INTO history (tid, bid, aid, delta, mtime)
     VALUES (:tid, :bid, :aid, :delta, CURRENT TIMESTAMP);
   END;




                         Greg Smith   Introduction to pgbench
Select only test




   set naccounts 100000 * :scale
   setrandom aid 1 :naccounts
   SELECT abalance FROM accounts WHERE aid = :aid;




                      Greg Smith   Introduction to pgbench
Creating a fairly large pgbench database




   # pgbench -i -s 100 pgbench
   select pg size pretty(pg database size(’pgbench’));
     1416 MB
   select pg size pretty(pg relation size(’accounts’));
     1240 MB
   select pg size pretty(pg relation size(’accounts pkey’));
     171 MB




                       Greg Smith   Introduction to pgbench
pgbench Read-Only Scaling - 1GB server




                     Greg Smith   Introduction to pgbench
pgbench Read-Only Scaling - 8GB server




                     Greg Smith   Introduction to pgbench
postgresql.conf parameters that matter



      shared buffers
      checkpoint segments
      autovacuum
      synchronous commit + wal writer delay
      wal buffers
      checkpoint completion target
      wal sync method

      http://wiki.postgresql.org/wiki/Tuning Your PostgreSQL Server




                         Greg Smith   Introduction to pgbench
postgresql.conf parameters that don’t matter




      effective cache size
      default statistics target
      work mem
      random page cost




                            Greg Smith   Introduction to pgbench
Gotchas


      Long enough runtime–1 minute or 100,000 transactions
      minimum
      Not paying attention to DB size relative to the various cache
      sizes
      Update contention warnings not as important
      pgbench client parsing and process switching limitations
      vacuum and bloating
      Checkpoints adding variation
      Custom scripts don’t detect scale
      Developer PostgreSQL builds



                          Greg Smith   Introduction to pgbench
pgbench-tools




      Set of shell scripts to automate running many pgbench tests
      Results are saved into a database for analysis
      Saves TPS, latency, background writer statistics
      Most of the cool features require PostgreSQL 8.3
      Inspired by the dbt2 benchmark framework




                          Greg Smith   Introduction to pgbench
Server configuration



      Quad-Core Intel Q6600
      8GB DDR2-800 RAM
      Areca ARC-1210 SATA II PCI-e x8 RAID controller, 256MB
      write cache
      DB: 3x160GB Maxtor SATA disks, Linux software RAID-0
      WAL: 160GB Maxtor SATA disk
      Linux Kernel 2.6.22 x86 64
      Untuned ext3 filesystems




                         Greg Smith   Introduction to pgbench
PostgreSQL Configuration




      PostgreSQL 8.4-devel
      shared buffers = 2GB
      checkpoint segments = 32
      checkpoint completion target = 0.9
      wal buffers = 128KB
      max connections = 100




                         Greg Smith   Introduction to pgbench
pgbench-tools Config




      SCALES=”1 2 3 4 6 7 8 9 10 15 20 25 30 35 50 75 100 150
      200 250 300 400 500 600 700 800”
      SCRIPT=”tpc-b.sql”
      TOTTRANS=200000
      SETTIMES=3
      SETCLIENTS=”1 2 3 4 8 16 24 32”




                        Greg Smith   Introduction to pgbench
pgbench TPC-B Size Scaling




                    Greg Smith   Introduction to pgbench
pgbench TPC-B Client Scaling




                    Greg Smith   Introduction to pgbench
pgbench TPC-B Size and Client Scaling
(3D glasses not included)




                     Greg Smith   Introduction to pgbench
Don’t be fooled by TPS


   scaling factor: 600
   number of clients: 8
   number of transactions per client: 25000
   number of transactions actually processed: 200000/200000
   tps = 226.228995 (including connections establishing)


   scaling factor: 600
   number of clients: 32
   number of transactions per client: 6250
   number of transactions actually processed: 200000/200000
   tps = 376.016694 (including connections establishing)

                         Greg Smith   Introduction to pgbench
Great result: scale=10, clients=8, tps=4054




                     Greg Smith   Introduction to pgbench
Mediocre result: scale=100, clients=24, tps=1354




                     Greg Smith   Introduction to pgbench
Bad result: scale=600, clients=8, tps=226




                     Greg Smith   Introduction to pgbench
Surprise! Awful result: scale=600, clients=32, tps=376




                      Greg Smith   Introduction to pgbench
Thorough testing takes a long time




   psql pgbench -c 
     quot;select sum(end time - start time) from testsquot;
   sum
   -----------------
   53:45:32.383059

         ...and even then you may not get it right!
         Need to aim for an equal number of checkpoints



                             Greg Smith   Introduction to pgbench
bgwriter stats - low scales

scale       tps          checkpoints buf check                buf alloc

1           2179         0                    46              2606

2           2510         0                    0               1357

3           2744         0                    0               1389

4           2891         0                    0               1419

5           2958         0                    179             2639

6           3062         0                    0               1483

7           3170         0                    0               1516

8           3154         0                    0               1548

9           3565         0                    0               1537
                       Greg Smith   Introduction to pgbench
bgwriter stats - medium scales

scale       tps         checkpoints buf check                buf alloc

10          3029        0                    548             2701

15          3359        0                    0               1704

20          3342        0                    0               1841

25          2937        1                    28295           2911

30          3385        1                    11898           3113

35          2905        2                    105911          3052

50          2001        4                    178967          6672

75          1509        5                    261757          8719

100         1203        6                    325074          10742
                      Greg Smith   Introduction to pgbench
bgwriter stats - high scales

scale       tps          checkpoints buf check                buf alloc

150         692          5                    264999          38239

200         633          5                    309983          137743

250         575          6                    333119          205253

300         643          11                   634055          506451

400         450          5                    313166          318942

500         285          6                    392441          380465

600         246          6                    404912          389897

700         217          6                    433745          435527

800         197          7                    456626          471071
                       Greg Smith   Introduction to pgbench
Cold vs. Warm Database Cache




      Results so far have all been warm cache
      Database initialization and benchmark run had no cache
      clearing in between
      This is fairly real-world once your app has been running for a
      while
      The situation just after a reboot will be far worse
      Both are interesting benchmark numbers, neither is ’right’




                          Greg Smith   Introduction to pgbench
Cold Cache Comparison

      The select-only test can work like a simple test to measure
      real-world row+index seeks/second over some data size
      Create a pgbench database with the size you want to test
      normally
      Clear all caches: reboot, on Linux you can use pg ctl stop plus
      drop caches
      Run the select only test, disabling any init/VACUUM steps
      (SKIPINIT feature)
      Watch bi column in vmstat to see effective seek MB/s
      At the beginning of the test, you’ll be fetching a lot of the
      index to the table along with the table
      That makes for two seeks per row until that’s populated.
      Can look at pg buffercache for more insight into when the
      index is all in RAM
                          Greg Smith   Introduction to pgbench
Warm cache: scale=100, clients=4, 1M transactions




                     Greg Smith   Introduction to pgbench
Cold cache: scale=100, clients=4, 1M transactions




                     Greg Smith   Introduction to pgbench
Zoom on start: low of 37 TPS




                    Greg Smith   Introduction to pgbench
Database typical row query


   select relname,relpages,reltuples,
   pg size pretty(pg relation size(relname::regclass))
    as relsize,
   round(pg relation size(relname::regclass) / reltuples)
    as quot;bytes per rowquot;,
   round(8192 / (pg relation size(relname::regclass)
    / reltuples)) as rows per page,
   round(1024*1024 / (pg relation size(relname::regclass)
    / reltuples)) as rows per mb
   from pg class where relname=’accounts’;

                          Greg Smith   Introduction to pgbench
Using seek rate to estimate fill time



  reltuples         relsize          bytes per row              rows per mb
  9.99977e+06       1240 MB          130                        8064

   Measured vmstat bo=1.1MB/s
   1.1 MB/s * 8064 rows/MB = 8870 rows/second
   Estimated cache fill time:
     10M rows / 8870 rows/sec = 1127 seconds = 18 minutes

       Database pages/MB are normally (1024*1024)/8192 = 128



                        Greg Smith    Introduction to pgbench
Cold Cache Fill Time Measurement



      Had reached near full warm cache speed, 16799 TPS, by the
      end of the run


   select end time - start time as run time from tests
     00:23:27.890015

      Didn’t account for index overhead
      Would have made estimate above even closer to reality




                         Greg Smith   Introduction to pgbench
Custom test: insert size



   create table data(filler text);


   insert into data (filler) values (repeat(’X’,:scale));


   SCALES=quot;10 100 1000 10000quot;
   SCRIPT=quot;insert-size.sqlquot;
   TOTTRANS=100000
   SETTIMES=1
   SETCLIENTS=quot;1 2 4 8 16quot;
   SKIPINIT=1

                      Greg Smith   Introduction to pgbench
Insert size quick test



             Scale

Clients      10            100                  1000            10000

1            1642          1611                 1621            1625

2            2139          2142                 2111            2232

4            3196          3306                 3232            3296

8            4728          5243                 5445            5038

16           9372          8309                 8140            7238



                         Greg Smith   Introduction to pgbench
Conclusions




      Pay attention to your database scale
      Client scaling may not work as you expect
      Automate your tests and be consistent how you run them
      Results in a database make life easier
      Generating pretty graphs isn’t just for marketing
      pgbench can be used for running your specific tests, too




                          Greg Smith   Introduction to pgbench

Más contenido relacionado

La actualidad más candente

Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres MonitoringDenish Patel
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
ClickHouse Materialized Views: The Magic Continues
ClickHouse Materialized Views: The Magic ContinuesClickHouse Materialized Views: The Magic Continues
ClickHouse Materialized Views: The Magic ContinuesAltinity Ltd
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PGConf APAC
 
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)NTT DATA Technology & Innovation
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?Mydbops
 
ProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationSuyog Shirgaonkar
 
Delta Lake: Optimizing Merge
Delta Lake: Optimizing MergeDelta Lake: Optimizing Merge
Delta Lake: Optimizing MergeDatabricks
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation FrameworkCaserta
 
NOSQLの基礎知識(講義資料)
NOSQLの基礎知識(講義資料)NOSQLの基礎知識(講義資料)
NOSQLの基礎知識(講義資料)CLOUDIAN KK
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance TuningMaven Logix
 
Data Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
Data Engineer's Lunch #83: Strategies for Migration to Apache IcebergData Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
Data Engineer's Lunch #83: Strategies for Migration to Apache IcebergAnant Corporation
 
Proxysql sharding
Proxysql shardingProxysql sharding
Proxysql shardingMarco Tusa
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsCommand Prompt., Inc
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우PgDay.Seoul
 

La actualidad más candente (20)

Postgresql
PostgresqlPostgresql
Postgresql
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres Monitoring
 
Postgre sql vs oracle
Postgre sql vs oraclePostgre sql vs oracle
Postgre sql vs oracle
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
ClickHouse Materialized Views: The Magic Continues
ClickHouse Materialized Views: The Magic ContinuesClickHouse Materialized Views: The Magic Continues
ClickHouse Materialized Views: The Magic Continues
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
PostgreSQL and RAM usage
PostgreSQL and RAM usagePostgreSQL and RAM usage
PostgreSQL and RAM usage
 
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
Memoizeの仕組み(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
ProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfiguration
 
Delta Lake: Optimizing Merge
Delta Lake: Optimizing MergeDelta Lake: Optimizing Merge
Delta Lake: Optimizing Merge
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
NOSQLの基礎知識(講義資料)
NOSQLの基礎知識(講義資料)NOSQLの基礎知識(講義資料)
NOSQLの基礎知識(講義資料)
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance Tuning
 
Data Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
Data Engineer's Lunch #83: Strategies for Migration to Apache IcebergData Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
Data Engineer's Lunch #83: Strategies for Migration to Apache Iceberg
 
Proxysql sharding
Proxysql shardingProxysql sharding
Proxysql sharding
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우
 

Destacado

PGPool-II Load testing
PGPool-II Load testingPGPool-II Load testing
PGPool-II Load testingEDB
 
PostgreSQL and Benchmarks
PostgreSQL and BenchmarksPostgreSQL and Benchmarks
PostgreSQL and BenchmarksJignesh Shah
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoMark Wong
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.confRobert Treat
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksJignesh Shah
 
Best Practices of running PostgreSQL in Virtual Environments
Best Practices of running PostgreSQL in Virtual EnvironmentsBest Practices of running PostgreSQL in Virtual Environments
Best Practices of running PostgreSQL in Virtual EnvironmentsJignesh Shah
 
AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...
AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...
AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...Amazon Web Services
 
Architecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterArchitecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterAshnikbiz
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6Tomas Vondra
 
NEW LAUNCH! Introducing PostgreSQL compatibility for Amazon Aurora
NEW LAUNCH! Introducing PostgreSQL compatibility for Amazon AuroraNEW LAUNCH! Introducing PostgreSQL compatibility for Amazon Aurora
NEW LAUNCH! Introducing PostgreSQL compatibility for Amazon AuroraAmazon Web Services
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
The Good, The Bad and The Greys of Data Visualisation Design
The Good, The Bad and The Greys of Data Visualisation DesignThe Good, The Bad and The Greys of Data Visualisation Design
The Good, The Bad and The Greys of Data Visualisation DesignAndy Kirk
 
Overview of Scientific Workflows - Why Use Them?
Overview of Scientific Workflows - Why Use Them?Overview of Scientific Workflows - Why Use Them?
Overview of Scientific Workflows - Why Use Them?inside-BigData.com
 

Destacado (14)

PGPool-II Load testing
PGPool-II Load testingPGPool-II Load testing
PGPool-II Load testing
 
PostgreSQL and Benchmarks
PostgreSQL and BenchmarksPostgreSQL and Benchmarks
PostgreSQL and Benchmarks
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.conf
 
Understanding PostgreSQL LW Locks
Understanding PostgreSQL LW LocksUnderstanding PostgreSQL LW Locks
Understanding PostgreSQL LW Locks
 
Best Practices of running PostgreSQL in Virtual Environments
Best Practices of running PostgreSQL in Virtual EnvironmentsBest Practices of running PostgreSQL in Virtual Environments
Best Practices of running PostgreSQL in Virtual Environments
 
AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...
AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...
AWS Webcast - Achieving consistent high performance with Postgres on Amazon W...
 
Architecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterArchitecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres Cluster
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6
 
NEW LAUNCH! Introducing PostgreSQL compatibility for Amazon Aurora
NEW LAUNCH! Introducing PostgreSQL compatibility for Amazon AuroraNEW LAUNCH! Introducing PostgreSQL compatibility for Amazon Aurora
NEW LAUNCH! Introducing PostgreSQL compatibility for Amazon Aurora
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
The Good, The Bad and The Greys of Data Visualisation Design
The Good, The Bad and The Greys of Data Visualisation DesignThe Good, The Bad and The Greys of Data Visualisation Design
The Good, The Bad and The Greys of Data Visualisation Design
 
Overview of Scientific Workflows - Why Use Them?
Overview of Scientific Workflows - Why Use Them?Overview of Scientific Workflows - Why Use Them?
Overview of Scientific Workflows - Why Use Them?
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 

Similar a Introduction to PgBench

Aplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sqlAplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sqlFabio Telles Rodriguez
 
OLTP+OLAP=HTAP
 OLTP+OLAP=HTAP OLTP+OLAP=HTAP
OLTP+OLAP=HTAPEDB
 
PL/CUDA - Fusion of HPC Grade Power with In-Database Analytics
PL/CUDA - Fusion of HPC Grade Power with In-Database AnalyticsPL/CUDA - Fusion of HPC Grade Power with In-Database Analytics
PL/CUDA - Fusion of HPC Grade Power with In-Database AnalyticsKohei KaiGai
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsSerge Smetana
 
Top-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTier1 app
 
Speedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql LoaderSpeedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql LoaderGregSmith458515
 
pgconfasia2016 plcuda en
pgconfasia2016 plcuda enpgconfasia2016 plcuda en
pgconfasia2016 plcuda enKohei KaiGai
 
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeAdaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeDatabricks
 
Become a Garbage Collection Hero
Become a Garbage Collection HeroBecome a Garbage Collection Hero
Become a Garbage Collection HeroTier1app
 
Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018Bastian Grimm
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceBrendan Gregg
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New FeaturesAmazon Web Services
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016Brendan Gregg
 
Building scalable web socket backend
Building scalable web socket backendBuilding scalable web socket backend
Building scalable web socket backendConstantine Slisenka
 
20180920_DBTS_PGStrom_EN
20180920_DBTS_PGStrom_EN20180920_DBTS_PGStrom_EN
20180920_DBTS_PGStrom_ENKohei KaiGai
 
ELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemAvleen Vig
 

Similar a Introduction to PgBench (20)

Aplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sqlAplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sql
 
Explain this!
Explain this!Explain this!
Explain this!
 
OLTP+OLAP=HTAP
 OLTP+OLAP=HTAP OLTP+OLAP=HTAP
OLTP+OLAP=HTAP
 
PgconfSV compression
PgconfSV compressionPgconfSV compression
PgconfSV compression
 
PL/CUDA - Fusion of HPC Grade Power with In-Database Analytics
PL/CUDA - Fusion of HPC Grade Power with In-Database AnalyticsPL/CUDA - Fusion of HPC Grade Power with In-Database Analytics
PL/CUDA - Fusion of HPC Grade Power with In-Database Analytics
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails Applications
 
Top-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
 
Speedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql LoaderSpeedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql Loader
 
pgconfasia2016 plcuda en
pgconfasia2016 plcuda enpgconfasia2016 plcuda en
pgconfasia2016 plcuda en
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeAdaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
 
Become a Garbage Collection Hero
Become a Garbage Collection HeroBecome a Garbage Collection Hero
Become a Garbage Collection Hero
 
Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018
 
test
testtest
test
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems Performance
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
Building scalable web socket backend
Building scalable web socket backendBuilding scalable web socket backend
Building scalable web socket backend
 
20180920_DBTS_PGStrom_EN
20180920_DBTS_PGStrom_EN20180920_DBTS_PGStrom_EN
20180920_DBTS_PGStrom_EN
 
ELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log systemELK: Moose-ively scaling your log system
ELK: Moose-ively scaling your log system
 

Más de Joshua Drake

Defining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own BusinessDefining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own BusinessJoshua Drake
 
Defining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own BusinessDefining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own BusinessJoshua Drake
 
An evening with Postgresql
An evening with PostgresqlAn evening with Postgresql
An evening with PostgresqlJoshua Drake
 
Dumb Simple PostgreSQL Performance (NYCPUG)
Dumb Simple PostgreSQL Performance (NYCPUG)Dumb Simple PostgreSQL Performance (NYCPUG)
Dumb Simple PostgreSQL Performance (NYCPUG)Joshua Drake
 
Developing A Procedural Language For Postgre Sql
Developing A Procedural Language For Postgre SqlDeveloping A Procedural Language For Postgre Sql
Developing A Procedural Language For Postgre SqlJoshua Drake
 
PostgreSQL Conference: East 08
PostgreSQL Conference: East 08PostgreSQL Conference: East 08
PostgreSQL Conference: East 08Joshua Drake
 
PostgreSQL Conference: West 08
PostgreSQL Conference: West 08PostgreSQL Conference: West 08
PostgreSQL Conference: West 08Joshua Drake
 
What MySQL can learn from PostgreSQL
What MySQL can learn from PostgreSQLWhat MySQL can learn from PostgreSQL
What MySQL can learn from PostgreSQLJoshua Drake
 
Northern Arizona State ACM talk (10/08)
Northern Arizona State ACM talk (10/08)Northern Arizona State ACM talk (10/08)
Northern Arizona State ACM talk (10/08)Joshua Drake
 

Más de Joshua Drake (13)

Defining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own BusinessDefining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own Business
 
Defining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own BusinessDefining Your Goal: Starting Your Own Business
Defining Your Goal: Starting Your Own Business
 
An evening with Postgresql
An evening with PostgresqlAn evening with Postgresql
An evening with Postgresql
 
Dumb Simple PostgreSQL Performance (NYCPUG)
Dumb Simple PostgreSQL Performance (NYCPUG)Dumb Simple PostgreSQL Performance (NYCPUG)
Dumb Simple PostgreSQL Performance (NYCPUG)
 
East09 Keynote
East09 KeynoteEast09 Keynote
East09 Keynote
 
Go Replicator
Go ReplicatorGo Replicator
Go Replicator
 
Pitr Made Easy
Pitr Made EasyPitr Made Easy
Pitr Made Easy
 
Developing A Procedural Language For Postgre Sql
Developing A Procedural Language For Postgre SqlDeveloping A Procedural Language For Postgre Sql
Developing A Procedural Language For Postgre Sql
 
PostgreSQL Conference: East 08
PostgreSQL Conference: East 08PostgreSQL Conference: East 08
PostgreSQL Conference: East 08
 
PostgreSQL Conference: West 08
PostgreSQL Conference: West 08PostgreSQL Conference: West 08
PostgreSQL Conference: West 08
 
What MySQL can learn from PostgreSQL
What MySQL can learn from PostgreSQLWhat MySQL can learn from PostgreSQL
What MySQL can learn from PostgreSQL
 
Northern Arizona State ACM talk (10/08)
Northern Arizona State ACM talk (10/08)Northern Arizona State ACM talk (10/08)
Northern Arizona State ACM talk (10/08)
 
Plproxy
PlproxyPlproxy
Plproxy
 

Último

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Introduction to PgBench

  • 1. Introduction to pgbench Greg Smith Truviso 04/05/2009 Greg Smith Introduction to pgbench
  • 2. About this presentation The master source for these slides is http://www.westnet.com/~gsmith/content/postgresql Slides are released under the Creative Commons Attribution 3.0 United States License See http://creativecommons.org/licenses/by/3.0/us Greg Smith Introduction to pgbench
  • 3. pgbench History TPC-B: http://www.tpc.org/tpcb/ State of the art...in 1990 Models a bank with accounts, tellers, and branches pgbench actually derived from JDBCbench http: //developer.mimer.com/features/feature_16.htm But aimed to eliminate Java overhead The JDBCbench code is buggy Early pgbench versions inherited some of those bugs Greg Smith Introduction to pgbench
  • 4. Database scale Each scale increment adds another branch to the database 1 branch + 10 tellers + 100000 accounts Total database size is approximately 16MB * scale createdb pgbench pgbench -i -s 10 scale=10 makes for a 160MB database Greg Smith Introduction to pgbench
  • 5. Database schema CREATE TABLE branches(bid int not null, bbalance int, filler char(88)); ALTER TABLE branches add primary key (bid); CREATE TABLE tellers(tid int not null,bid int, tbalance int,filler char(84)); ALTER TABLE tellers add primary key (tid); CREATE TABLE accounts(aid int not null,bid int, abalance int,filler char(84)); ALTER TABLE accounts add primary key (aid); CREATE TABLE history(tid int,bid int,aid int,delta int, mtime timestamp,filler char(22)); Greg Smith Introduction to pgbench
  • 6. Filler Filler itended to make each row at least 100 bytes long Fail: null data inserted into it doesn’t do that Rows are therefore very narrow Not fixed because it would put new pgbench results on a different scale Greg Smith Introduction to pgbench
  • 7. Scripting language set nbranches :scale set ntellers 10 * :scale set naccounts 100000 * :scale setrandom aid 1 :naccounts setrandom bid 1 :nbranches setrandom tid 1 :ntellers setrandom delta -5000 5000 Greg Smith Introduction to pgbench
  • 8. Standard test 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; Greg Smith Introduction to pgbench
  • 9. No teller/branch test BEGIN; UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid; SELECT abalance FROM accounts WHERE aid = :aid; INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT TIMESTAMP); END; Greg Smith Introduction to pgbench
  • 10. Select only test set naccounts 100000 * :scale setrandom aid 1 :naccounts SELECT abalance FROM accounts WHERE aid = :aid; Greg Smith Introduction to pgbench
  • 11. Creating a fairly large pgbench database # pgbench -i -s 100 pgbench select pg size pretty(pg database size(’pgbench’)); 1416 MB select pg size pretty(pg relation size(’accounts’)); 1240 MB select pg size pretty(pg relation size(’accounts pkey’)); 171 MB Greg Smith Introduction to pgbench
  • 12. pgbench Read-Only Scaling - 1GB server Greg Smith Introduction to pgbench
  • 13. pgbench Read-Only Scaling - 8GB server Greg Smith Introduction to pgbench
  • 14. postgresql.conf parameters that matter shared buffers checkpoint segments autovacuum synchronous commit + wal writer delay wal buffers checkpoint completion target wal sync method http://wiki.postgresql.org/wiki/Tuning Your PostgreSQL Server Greg Smith Introduction to pgbench
  • 15. postgresql.conf parameters that don’t matter effective cache size default statistics target work mem random page cost Greg Smith Introduction to pgbench
  • 16. Gotchas Long enough runtime–1 minute or 100,000 transactions minimum Not paying attention to DB size relative to the various cache sizes Update contention warnings not as important pgbench client parsing and process switching limitations vacuum and bloating Checkpoints adding variation Custom scripts don’t detect scale Developer PostgreSQL builds Greg Smith Introduction to pgbench
  • 17. pgbench-tools Set of shell scripts to automate running many pgbench tests Results are saved into a database for analysis Saves TPS, latency, background writer statistics Most of the cool features require PostgreSQL 8.3 Inspired by the dbt2 benchmark framework Greg Smith Introduction to pgbench
  • 18. Server configuration Quad-Core Intel Q6600 8GB DDR2-800 RAM Areca ARC-1210 SATA II PCI-e x8 RAID controller, 256MB write cache DB: 3x160GB Maxtor SATA disks, Linux software RAID-0 WAL: 160GB Maxtor SATA disk Linux Kernel 2.6.22 x86 64 Untuned ext3 filesystems Greg Smith Introduction to pgbench
  • 19. PostgreSQL Configuration PostgreSQL 8.4-devel shared buffers = 2GB checkpoint segments = 32 checkpoint completion target = 0.9 wal buffers = 128KB max connections = 100 Greg Smith Introduction to pgbench
  • 20. pgbench-tools Config SCALES=”1 2 3 4 6 7 8 9 10 15 20 25 30 35 50 75 100 150 200 250 300 400 500 600 700 800” SCRIPT=”tpc-b.sql” TOTTRANS=200000 SETTIMES=3 SETCLIENTS=”1 2 3 4 8 16 24 32” Greg Smith Introduction to pgbench
  • 21. pgbench TPC-B Size Scaling Greg Smith Introduction to pgbench
  • 22. pgbench TPC-B Client Scaling Greg Smith Introduction to pgbench
  • 23. pgbench TPC-B Size and Client Scaling (3D glasses not included) Greg Smith Introduction to pgbench
  • 24. Don’t be fooled by TPS scaling factor: 600 number of clients: 8 number of transactions per client: 25000 number of transactions actually processed: 200000/200000 tps = 226.228995 (including connections establishing) scaling factor: 600 number of clients: 32 number of transactions per client: 6250 number of transactions actually processed: 200000/200000 tps = 376.016694 (including connections establishing) Greg Smith Introduction to pgbench
  • 25. Great result: scale=10, clients=8, tps=4054 Greg Smith Introduction to pgbench
  • 26. Mediocre result: scale=100, clients=24, tps=1354 Greg Smith Introduction to pgbench
  • 27. Bad result: scale=600, clients=8, tps=226 Greg Smith Introduction to pgbench
  • 28. Surprise! Awful result: scale=600, clients=32, tps=376 Greg Smith Introduction to pgbench
  • 29. Thorough testing takes a long time psql pgbench -c quot;select sum(end time - start time) from testsquot; sum ----------------- 53:45:32.383059 ...and even then you may not get it right! Need to aim for an equal number of checkpoints Greg Smith Introduction to pgbench
  • 30. bgwriter stats - low scales scale tps checkpoints buf check buf alloc 1 2179 0 46 2606 2 2510 0 0 1357 3 2744 0 0 1389 4 2891 0 0 1419 5 2958 0 179 2639 6 3062 0 0 1483 7 3170 0 0 1516 8 3154 0 0 1548 9 3565 0 0 1537 Greg Smith Introduction to pgbench
  • 31. bgwriter stats - medium scales scale tps checkpoints buf check buf alloc 10 3029 0 548 2701 15 3359 0 0 1704 20 3342 0 0 1841 25 2937 1 28295 2911 30 3385 1 11898 3113 35 2905 2 105911 3052 50 2001 4 178967 6672 75 1509 5 261757 8719 100 1203 6 325074 10742 Greg Smith Introduction to pgbench
  • 32. bgwriter stats - high scales scale tps checkpoints buf check buf alloc 150 692 5 264999 38239 200 633 5 309983 137743 250 575 6 333119 205253 300 643 11 634055 506451 400 450 5 313166 318942 500 285 6 392441 380465 600 246 6 404912 389897 700 217 6 433745 435527 800 197 7 456626 471071 Greg Smith Introduction to pgbench
  • 33. Cold vs. Warm Database Cache Results so far have all been warm cache Database initialization and benchmark run had no cache clearing in between This is fairly real-world once your app has been running for a while The situation just after a reboot will be far worse Both are interesting benchmark numbers, neither is ’right’ Greg Smith Introduction to pgbench
  • 34. Cold Cache Comparison The select-only test can work like a simple test to measure real-world row+index seeks/second over some data size Create a pgbench database with the size you want to test normally Clear all caches: reboot, on Linux you can use pg ctl stop plus drop caches Run the select only test, disabling any init/VACUUM steps (SKIPINIT feature) Watch bi column in vmstat to see effective seek MB/s At the beginning of the test, you’ll be fetching a lot of the index to the table along with the table That makes for two seeks per row until that’s populated. Can look at pg buffercache for more insight into when the index is all in RAM Greg Smith Introduction to pgbench
  • 35. Warm cache: scale=100, clients=4, 1M transactions Greg Smith Introduction to pgbench
  • 36. Cold cache: scale=100, clients=4, 1M transactions Greg Smith Introduction to pgbench
  • 37. Zoom on start: low of 37 TPS Greg Smith Introduction to pgbench
  • 38. Database typical row query select relname,relpages,reltuples, pg size pretty(pg relation size(relname::regclass)) as relsize, round(pg relation size(relname::regclass) / reltuples) as quot;bytes per rowquot;, round(8192 / (pg relation size(relname::regclass) / reltuples)) as rows per page, round(1024*1024 / (pg relation size(relname::regclass) / reltuples)) as rows per mb from pg class where relname=’accounts’; Greg Smith Introduction to pgbench
  • 39. Using seek rate to estimate fill time reltuples relsize bytes per row rows per mb 9.99977e+06 1240 MB 130 8064 Measured vmstat bo=1.1MB/s 1.1 MB/s * 8064 rows/MB = 8870 rows/second Estimated cache fill time: 10M rows / 8870 rows/sec = 1127 seconds = 18 minutes Database pages/MB are normally (1024*1024)/8192 = 128 Greg Smith Introduction to pgbench
  • 40. Cold Cache Fill Time Measurement Had reached near full warm cache speed, 16799 TPS, by the end of the run select end time - start time as run time from tests 00:23:27.890015 Didn’t account for index overhead Would have made estimate above even closer to reality Greg Smith Introduction to pgbench
  • 41. Custom test: insert size create table data(filler text); insert into data (filler) values (repeat(’X’,:scale)); SCALES=quot;10 100 1000 10000quot; SCRIPT=quot;insert-size.sqlquot; TOTTRANS=100000 SETTIMES=1 SETCLIENTS=quot;1 2 4 8 16quot; SKIPINIT=1 Greg Smith Introduction to pgbench
  • 42. Insert size quick test Scale Clients 10 100 1000 10000 1 1642 1611 1621 1625 2 2139 2142 2111 2232 4 3196 3306 3232 3296 8 4728 5243 5445 5038 16 9372 8309 8140 7238 Greg Smith Introduction to pgbench
  • 43. Conclusions Pay attention to your database scale Client scaling may not work as you expect Automate your tests and be consistent how you run them Results in a database make life easier Generating pretty graphs isn’t just for marketing pgbench can be used for running your specific tests, too Greg Smith Introduction to pgbench