Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > bab02a23fa9f3df8d66a9a3231b50245 > files > 392

postgresql8.3-docs-8.3.6-2mdv2008.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pgbench</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.3.6 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Additional Supplied Modules"
HREF="contrib.html"><LINK
REL="PREVIOUS"
TITLE="pageinspect"
HREF="pageinspect.html"><LINK
REL="NEXT"
TITLE="pg_buffercache"
HREF="pgbuffercache.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2009-02-03T04:34:16"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.3.6 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="pageinspect.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="contrib.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Appendix F. Additional Supplied Modules</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="contrib.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="pgbuffercache.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="PGBENCH"
>F.18. pgbench</A
></H1
><A
NAME="AEN101985"
></A
><P
>  <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> is a simple program for running benchmark
  tests on <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>.  It runs the same sequence of SQL
  commands over and over, possibly in multiple concurrent database sessions,
  and then calculates the average transaction rate (transactions per second).
  By default, <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> tests a scenario that is
  loosely based on TPC-B, involving five <TT
CLASS="COMMAND"
>SELECT</TT
>,
  <TT
CLASS="COMMAND"
>UPDATE</TT
>, and <TT
CLASS="COMMAND"
>INSERT</TT
> commands per transaction.
  However, it is easy to test other cases by writing your own transaction
  script files.
 </P
><P
>  Typical output from pgbench looks like:

 </P><PRE
CLASS="PROGRAMLISTING"
>transaction type: TPC-B (sort of)
scaling factor: 10
number of clients: 10
number of transactions per client: 1000
number of transactions actually processed: 10000/10000
tps = 85.184871 (including connections establishing)
tps = 85.296346 (excluding connections establishing)
 </PRE
><P>

  The first four lines just report some of the most important parameter
  settings.  The next line reports the number of transactions completed
  and intended (the latter being just the product of number of clients
  and number of transactions); these will be equal unless the run
  failed before completion.  The last two lines report the TPS rate,
  figured with and without counting the time to start database sessions.
 </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN101996"
>F.18.1. Overview</A
></H2
><P
>   The default TPC-B-like transaction test requires specific tables to be
   set up beforehand.  <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> should be invoked with
   the <TT
CLASS="LITERAL"
>-i</TT
> (initialize) option to create and populate these
   tables.  (When you are testing a custom script, you don't need this
   step, but will instead need to do whatever setup your test needs.)
   Initialization looks like:

   </P><PRE
CLASS="PROGRAMLISTING"
>pgbench -i [<SPAN
CLASS="OPTIONAL"
> <TT
CLASS="REPLACEABLE"
><I
>other-options</I
></TT
> </SPAN
>] <TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
>
   </PRE
><P>

   where <TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
> is the name of the already-created
   database to test in.  (You may also need <TT
CLASS="LITERAL"
>-h</TT
>,
   <TT
CLASS="LITERAL"
>-p</TT
>, and/or <TT
CLASS="LITERAL"
>-U</TT
> options to specify how to
   connect to the database server.)
  </P
><DIV
CLASS="CAUTION"
><P
></P
><TABLE
CLASS="CAUTION"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>Caution</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>    <TT
CLASS="LITERAL"
>pgbench -i</TT
> creates four tables <TT
CLASS="STRUCTNAME"
>accounts</TT
>,
    <TT
CLASS="STRUCTNAME"
>branches</TT
>, <TT
CLASS="STRUCTNAME"
>history</TT
>, and
    <TT
CLASS="STRUCTNAME"
>tellers</TT
>, destroying any existing tables of these names.
    Be very careful to use another database if you have tables having these
    names!
   </P
></TD
></TR
></TABLE
></DIV
><P
>   At the default <SPAN
CLASS="QUOTE"
>"scale factor"</SPAN
> of 1, the tables initially
   contain this many rows:
  </P
><PRE
CLASS="PROGRAMLISTING"
>table           # of rows
-------------------------
branches        1
tellers         10
accounts        100000
history         0
  </PRE
><P
>   You can (and, for most purposes, probably should) increase the number
   of rows by using the <TT
CLASS="LITERAL"
>-s</TT
> (scale factor) option.  The
   <TT
CLASS="LITERAL"
>-F</TT
> (fillfactor) option might also be used at this point.
  </P
><P
>   Once you have done the necessary setup, you can run your benchmark
   with a command that doesn't include <TT
CLASS="LITERAL"
>-i</TT
>, that is

   </P><PRE
CLASS="PROGRAMLISTING"
>pgbench [<SPAN
CLASS="OPTIONAL"
> <TT
CLASS="REPLACEABLE"
><I
>options</I
></TT
> </SPAN
>] <TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
>
   </PRE
><P>

   In nearly all cases, you'll need some options to make a useful test.
   The most important options are <TT
CLASS="LITERAL"
>-c</TT
> (number of clients),
   <TT
CLASS="LITERAL"
>-t</TT
> (number of transactions), and <TT
CLASS="LITERAL"
>-f</TT
> (specify
   a custom script file).  See below for a full list.
  </P
><P
>   <A
HREF="pgbench.html#PGBENCH-INIT-OPTIONS"
>Table F-14</A
> shows options that are used
   during database initialization, while
   <A
HREF="pgbench.html#PGBENCH-RUN-OPTIONS"
>Table F-15</A
> shows options that are used
   while running benchmarks, and
   <A
HREF="pgbench.html#PGBENCH-COMMON-OPTIONS"
>Table F-16</A
> shows options that are useful
   in both cases.
  </P
><DIV
CLASS="TABLE"
><A
NAME="PGBENCH-INIT-OPTIONS"
></A
><P
><B
>Table F-14. <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> initialization options</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Option</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="LITERAL"
>-i</TT
></TD
><TD
>       Required to invoke initialization mode.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-s</TT
> <TT
CLASS="REPLACEABLE"
><I
>scale_factor</I
></TT
></TD
><TD
>       Multiply the number of rows generated by the scale factor.
       For example, <TT
CLASS="LITERAL"
>-s 100</TT
> will imply 10,000,000 rows
       in the <TT
CLASS="STRUCTNAME"
>accounts</TT
> table. Default is 1.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-F</TT
> <TT
CLASS="REPLACEABLE"
><I
>fillfactor</I
></TT
></TD
><TD
>       Create the <TT
CLASS="STRUCTNAME"
>accounts</TT
>, <TT
CLASS="STRUCTNAME"
>tellers</TT
> and
       <TT
CLASS="STRUCTNAME"
>branches</TT
> tables with the given fillfactor.
       Default is 100.
      </TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="TABLE"
><A
NAME="PGBENCH-RUN-OPTIONS"
></A
><P
><B
>Table F-15. <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> benchmarking options</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Option</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="LITERAL"
>-c</TT
> <TT
CLASS="REPLACEABLE"
><I
>clients</I
></TT
></TD
><TD
>       Number of clients simulated, that is, number of concurrent database
       sessions.  Default is 1.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-t</TT
> <TT
CLASS="REPLACEABLE"
><I
>transactions</I
></TT
></TD
><TD
>       Number of transactions each client runs.  Default is 10.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-N</TT
></TD
><TD
>       Do not update <TT
CLASS="STRUCTNAME"
>tellers</TT
> and <TT
CLASS="STRUCTNAME"
>branches</TT
>.
       This will avoid update contention on these tables, but
       it makes the test case even less like TPC-B.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-S</TT
></TD
><TD
>       Perform select-only transactions instead of TPC-B-like test.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-f</TT
> <TT
CLASS="REPLACEABLE"
><I
>filename</I
></TT
></TD
><TD
>       Read transaction script from <TT
CLASS="REPLACEABLE"
><I
>filename</I
></TT
>.
       See below for details.
       <TT
CLASS="LITERAL"
>-N</TT
>, <TT
CLASS="LITERAL"
>-S</TT
>, and <TT
CLASS="LITERAL"
>-f</TT
>
       are mutually exclusive.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-n</TT
></TD
><TD
>       No vacuuming is performed before running the test.
       This option is <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>necessary</I
></SPAN
>
       if you are running a custom test scenario that does not include
       the standard tables <TT
CLASS="STRUCTNAME"
>accounts</TT
>,
       <TT
CLASS="STRUCTNAME"
>branches</TT
>, <TT
CLASS="STRUCTNAME"
>history</TT
>, and
       <TT
CLASS="STRUCTNAME"
>tellers</TT
>.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-v</TT
></TD
><TD
>       Vacuum all four standard tables before running the test.
       With neither <TT
CLASS="LITERAL"
>-n</TT
> nor <TT
CLASS="LITERAL"
>-v</TT
>, pgbench will vacuum
       <TT
CLASS="STRUCTNAME"
>tellers</TT
> and <TT
CLASS="STRUCTNAME"
>branches</TT
> tables, and
       will remove all entries in <TT
CLASS="STRUCTNAME"
>history</TT
>.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-D</TT
> <TT
CLASS="REPLACEABLE"
><I
>varname</I
></TT
><TT
CLASS="LITERAL"
>=</TT
><TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
></TD
><TD
>       Define a variable for use by a custom script (see below).
       Multiple <TT
CLASS="LITERAL"
>-D</TT
> options are allowed.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-C</TT
></TD
><TD
>       Establish a new connection for each transaction, rather than
       doing it just once per client thread.
       This is useful to measure the connection overhead.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-l</TT
></TD
><TD
>       Write the time taken by each transaction to a logfile.
       See below for details.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-s</TT
> <TT
CLASS="REPLACEABLE"
><I
>scale_factor</I
></TT
></TD
><TD
>       Report the specified scale factor in <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
>'s
       output.  With the built-in tests, this is not necessary; the
       correct scale factor will be detected by counting the number of
       rows in the <TT
CLASS="STRUCTNAME"
>branches</TT
> table.  However, when testing
       custom benchmarks (<TT
CLASS="LITERAL"
>-f</TT
> option), the scale factor
       will be reported as 1 unless this option is used.
      </TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-d</TT
></TD
><TD
>       Print debugging output.
      </TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="TABLE"
><A
NAME="PGBENCH-COMMON-OPTIONS"
></A
><P
><B
>Table F-16. <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> common options</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Option</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="LITERAL"
>-h</TT
> <TT
CLASS="REPLACEABLE"
><I
>hostname</I
></TT
></TD
><TD
>database server's host</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-p</TT
> <TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
></TD
><TD
>database server's port</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>-U</TT
> <TT
CLASS="REPLACEABLE"
><I
>login</I
></TT
></TD
><TD
>username to connect as</TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN102171"
>F.18.2. What is the <SPAN
CLASS="QUOTE"
>"transaction"</SPAN
> actually performed in pgbench?</A
></H2
><P
>   The default transaction script issues seven commands per transaction:
  </P
><P
></P
><OL
TYPE="1"
><LI
><P
><TT
CLASS="LITERAL"
>BEGIN;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>SELECT abalance FROM accounts WHERE aid = :aid;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>UPDATE tellers SET tbalance = tbalance + :delta WHERE tid = :tid;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>UPDATE branches SET bbalance = bbalance + :delta WHERE bid = :bid;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>END;</TT
></P
></LI
></OL
><P
>   If you specify <TT
CLASS="LITERAL"
>-N</TT
>, steps 4 and 5 aren't included in the
   transaction.  If you specify <TT
CLASS="LITERAL"
>-S</TT
>, only the <TT
CLASS="COMMAND"
>SELECT</TT
> is
   issued.
  </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN102201"
>F.18.3. Custom Scripts</A
></H2
><P
>   <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> has support for running custom
   benchmark scenarios by replacing the default transaction script
   (described above) with a transaction script read from a file
   (<TT
CLASS="LITERAL"
>-f</TT
> option).  In this case a <SPAN
CLASS="QUOTE"
>"transaction"</SPAN
>
   counts as one execution of a script file.  You can even specify
   multiple scripts (multiple <TT
CLASS="LITERAL"
>-f</TT
> options), in which
   case a random one of the scripts is chosen each time a client session
   starts a new transaction.
  </P
><P
>   The format of a script file is one SQL command per line; multi-line
   SQL commands are not supported.  Empty lines and lines beginning with
   <TT
CLASS="LITERAL"
>--</TT
> are ignored.  Script file lines can also be
   <SPAN
CLASS="QUOTE"
>"meta commands"</SPAN
>, which are interpreted by <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
>
   itself, as described below.
  </P
><P
>   There is a simple variable-substitution facility for script files.
   Variables can be set by the command-line <TT
CLASS="LITERAL"
>-D</TT
> option,
   explained above, or by the meta commands explained below.
   In addition to any variables preset by <TT
CLASS="LITERAL"
>-D</TT
> command-line options,
   the variable <TT
CLASS="LITERAL"
>scale</TT
> is preset to the current scale factor.
   Once set, a variable's
   value can be inserted into a SQL command by writing
   <TT
CLASS="LITERAL"
>:</TT
><TT
CLASS="REPLACEABLE"
><I
>variablename</I
></TT
>.  When running more than
   one client session, each session has its own set of variables.
  </P
><P
>   Script file meta commands begin with a backslash (<TT
CLASS="LITERAL"
>\</TT
>).
   Arguments to a meta command are separated by white space.
   These meta commands are supported:
  </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>\set <TT
CLASS="REPLACEABLE"
><I
>varname</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>operand1</I
></TT
> [ <TT
CLASS="REPLACEABLE"
><I
>operator</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>operand2</I
></TT
> ]</TT
></DT
><DD
><P
>      Sets variable <TT
CLASS="REPLACEABLE"
><I
>varname</I
></TT
> to a calculated integer value.
      Each <TT
CLASS="REPLACEABLE"
><I
>operand</I
></TT
> is either an integer constant or a
      <TT
CLASS="LITERAL"
>:</TT
><TT
CLASS="REPLACEABLE"
><I
>variablename</I
></TT
> reference to a variable
      having an integer value.  The <TT
CLASS="REPLACEABLE"
><I
>operator</I
></TT
> can be
      <TT
CLASS="LITERAL"
>+</TT
>, <TT
CLASS="LITERAL"
>-</TT
>, <TT
CLASS="LITERAL"
>*</TT
>, or <TT
CLASS="LITERAL"
>/</TT
>.
     </P
><P
>      Example:
      </P><PRE
CLASS="PROGRAMLISTING"
>\set ntellers 10 * :scale
      </PRE
><P>
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>\setrandom <TT
CLASS="REPLACEABLE"
><I
>varname</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>min</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>max</I
></TT
></TT
></DT
><DD
><P
>      Sets variable <TT
CLASS="REPLACEABLE"
><I
>varname</I
></TT
> to a random integer value
      between the limits <TT
CLASS="REPLACEABLE"
><I
>min</I
></TT
> and <TT
CLASS="REPLACEABLE"
><I
>max</I
></TT
>.
      Each limit can be either an integer constant or a
      <TT
CLASS="LITERAL"
>:</TT
><TT
CLASS="REPLACEABLE"
><I
>variablename</I
></TT
> reference to a variable
      having an integer value.
     </P
><P
>      Example:
      </P><PRE
CLASS="PROGRAMLISTING"
>\setrandom aid 1 :naccounts
      </PRE
><P>
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>\sleep <TT
CLASS="REPLACEABLE"
><I
>number</I
></TT
> [ us | ms | s ]</TT
></DT
><DD
><P
>      Causes script execution to sleep for the specified duration in
      microseconds (<TT
CLASS="LITERAL"
>us</TT
>), milliseconds (<TT
CLASS="LITERAL"
>ms</TT
>) or seconds
      (<TT
CLASS="LITERAL"
>s</TT
>).  If the unit is omitted then seconds are the default.
      <TT
CLASS="REPLACEABLE"
><I
>number</I
></TT
> can be either an integer constant or a
      <TT
CLASS="LITERAL"
>:</TT
><TT
CLASS="REPLACEABLE"
><I
>variablename</I
></TT
> reference to a variable
      having an integer value.
     </P
><P
>      Example:
      </P><PRE
CLASS="PROGRAMLISTING"
>\sleep 10 ms
      </PRE
><P>
     </P
></DD
></DL
></DIV
><P
>   As an example, the full definition of the built-in TPC-B-like
   transaction is:

   </P><PRE
CLASS="PROGRAMLISTING"
>\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
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;
   </PRE
><P>

   This script allows each iteration of the transaction to reference
   different, randomly-chosen rows.  (This example also shows why it's
   important for each client session to have its own variables &mdash;
   otherwise they'd not be independently touching different rows.)
  </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN102272"
>F.18.4. Per-transaction logging</A
></H2
><P
>   With the <TT
CLASS="LITERAL"
>-l</TT
> option, <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> writes the time
   taken by each transaction to a logfile.  The logfile will be named
   <TT
CLASS="FILENAME"
>pgbench_log.<TT
CLASS="REPLACEABLE"
><I
>nnn</I
></TT
></TT
>, where
   <TT
CLASS="REPLACEABLE"
><I
>nnn</I
></TT
> is the PID of the pgbench process.
   The format of the log is:

   </P><PRE
CLASS="PROGRAMLISTING"
>    <TT
CLASS="REPLACEABLE"
><I
>client_id</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>transaction_no</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>time</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>file_no</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>time_epoch</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>time_us</I
></TT
>
   </PRE
><P>

   where <TT
CLASS="REPLACEABLE"
><I
>time</I
></TT
> is the elapsed transaction time in microseconds,
   <TT
CLASS="REPLACEABLE"
><I
>file_no</I
></TT
> identifies which script file was used
   (useful when multiple scripts were specified with <TT
CLASS="LITERAL"
>-f</TT
>),
   and <TT
CLASS="REPLACEABLE"
><I
>time_epoch</I
></TT
>/<TT
CLASS="REPLACEABLE"
><I
>time_us</I
></TT
> are a
   UNIX epoch format timestamp and an offset
   in microseconds (suitable for creating a ISO 8601
   timestamp with fractional seconds) showing when
   the transaction completed.
  </P
><P
>   Here are example outputs:
   </P><PRE
CLASS="PROGRAMLISTING"
> 0 199 2241 0 1175850568 995598
 0 200 2465 0 1175850568 998079
 0 201 2513 0 1175850569 608
 0 202 2038 0 1175850569 2663
   </PRE
><P>
  </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN102294"
>F.18.5. Good Practices</A
></H2
><P
>   It is very easy to use <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> to produce completely
   meaningless numbers.  Here are some guidelines to help you get useful
   results.
  </P
><P
>   In the first place, <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>never</I
></SPAN
> believe any test that runs
   for only a few seconds.  Increase the <TT
CLASS="LITERAL"
>-t</TT
> setting enough
   to make the run last at least a few minutes, so as to average out noise.
   In some cases you could need hours to get numbers that are reproducible.
   It's a good idea to try the test run a few times, to find out if your
   numbers are reproducible or not.
  </P
><P
>   For the default TPC-B-like test scenario, the initialization scale factor
   (<TT
CLASS="LITERAL"
>-s</TT
>) should be at least as large as the largest number of
   clients you intend to test (<TT
CLASS="LITERAL"
>-c</TT
>); else you'll mostly be
   measuring update contention.  There are only <TT
CLASS="LITERAL"
>-s</TT
> rows in
   the <TT
CLASS="STRUCTNAME"
>branches</TT
> table, and every transaction wants to
   update one of them, so <TT
CLASS="LITERAL"
>-c</TT
> values in excess of <TT
CLASS="LITERAL"
>-s</TT
>
   will undoubtedly result in lots of transactions blocked waiting for
   other transactions.
  </P
><P
>   The default test scenario is also quite sensitive to how long it's been
   since the tables were initialized: accumulation of dead rows and dead space
   in the tables changes the results.  To understand the results you must keep
   track of the total number of updates and when vacuuming happens.  If
   autovacuum is enabled it can result in unpredictable changes in measured
   performance.
  </P
><P
>   A limitation of <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> is that it can itself become
   the bottleneck when trying to test a large number of client sessions.
   This can be alleviated by running <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
> on a different
   machine from the database server, although low network latency will be
   essential.  It might even be useful to run several <SPAN
CLASS="APPLICATION"
>pgbench</SPAN
>
   instances concurrently, on several client machines, against the same
   database server.
  </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="pageinspect.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="pgbuffercache.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>pageinspect</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="contrib.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>pg_buffercache</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>