gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

883 lines
78KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pgbench</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="app-pgbasebackup.html" title="pg_basebackup" /><link rel="next" href="app-pgconfig.html" title="pg_config" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span xmlns="http://www.w3.org/1999/xhtml" class="application">pgbench</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgbasebackup.html" title="pg_basebackup">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgconfig.html" title="pg_config">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="PGBENCH"><div class="titlepage"></div><a id="id-1.9.4.10.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pgbench</span></span></h2><p>pgbench — run a benchmark test on <span class="productname">PostgreSQL</span></p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.10.4.1"><code class="command">pgbench</code> <code class="option">-i</code> [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.4.10.4.2"><code class="command">pgbench</code> [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>]</p></div></div><div class="refsect1" id="id-1.9.4.10.5"><h2>Description</h2><p>
  3. <span class="application">pgbench</span> is a simple program for running benchmark
  4. tests on <span class="productname">PostgreSQL</span>. It runs the same sequence of SQL
  5. commands over and over, possibly in multiple concurrent database sessions,
  6. and then calculates the average transaction rate (transactions per second).
  7. By default, <span class="application">pgbench</span> tests a scenario that is
  8. loosely based on TPC-B, involving five <code class="command">SELECT</code>,
  9. <code class="command">UPDATE</code>, and <code class="command">INSERT</code> commands per transaction.
  10. However, it is easy to test other cases by writing your own transaction
  11. script files.
  12. </p><p>
  13. Typical output from <span class="application">pgbench</span> looks like:
  14. </p><pre class="screen">
  15. transaction type: &lt;builtin: TPC-B (sort of)&gt;
  16. scaling factor: 10
  17. query mode: simple
  18. number of clients: 10
  19. number of threads: 1
  20. number of transactions per client: 1000
  21. number of transactions actually processed: 10000/10000
  22. tps = 85.184871 (including connections establishing)
  23. tps = 85.296346 (excluding connections establishing)
  24. </pre><p>
  25. The first six lines report some of the most important parameter
  26. settings. The next line reports the number of transactions completed
  27. and intended (the latter being just the product of number of clients
  28. and number of transactions per client); these will be equal unless the run
  29. failed before completion. (In <code class="option">-T</code> mode, only the actual
  30. number of transactions is printed.)
  31. The last two lines report the number of transactions per second,
  32. figured with and without counting the time to start database sessions.
  33. </p><p>
  34. The default TPC-B-like transaction test requires specific tables to be
  35. set up beforehand. <span class="application">pgbench</span> should be invoked with
  36. the <code class="option">-i</code> (initialize) option to create and populate these
  37. tables. (When you are testing a custom script, you don't need this
  38. step, but will instead need to do whatever setup your test needs.)
  39. Initialization looks like:
  40. </p><pre class="programlisting">
  41. pgbench -i [<span class="optional"> <em class="replaceable"><code>other-options</code></em> </span>] <em class="replaceable"><code>dbname</code></em>
  42. </pre><p>
  43. where <em class="replaceable"><code>dbname</code></em> is the name of the already-created
  44. database to test in. (You may also need <code class="option">-h</code>,
  45. <code class="option">-p</code>, and/or <code class="option">-U</code> options to specify how to
  46. connect to the database server.)
  47. </p><div class="caution"><h3 class="title">Caution</h3><p>
  48. <code class="literal">pgbench -i</code> creates four tables <code class="structname">pgbench_accounts</code>,
  49. <code class="structname">pgbench_branches</code>, <code class="structname">pgbench_history</code>, and
  50. <code class="structname">pgbench_tellers</code>,
  51. destroying any existing tables of these names.
  52. Be very careful to use another database if you have tables having these
  53. names!
  54. </p></div><p>
  55. At the default <span class="quote">“<span class="quote">scale factor</span>”</span> of 1, the tables initially
  56. contain this many rows:
  57. </p><pre class="screen">
  58. table # of rows
  59. ---------------------------------
  60. pgbench_branches 1
  61. pgbench_tellers 10
  62. pgbench_accounts 100000
  63. pgbench_history 0
  64. </pre><p>
  65. You can (and, for most purposes, probably should) increase the number
  66. of rows by using the <code class="option">-s</code> (scale factor) option. The
  67. <code class="option">-F</code> (fillfactor) option might also be used at this point.
  68. </p><p>
  69. Once you have done the necessary setup, you can run your benchmark
  70. with a command that doesn't include <code class="option">-i</code>, that is
  71. </p><pre class="programlisting">
  72. pgbench [<span class="optional"> <em class="replaceable"><code>options</code></em> </span>] <em class="replaceable"><code>dbname</code></em>
  73. </pre><p>
  74. In nearly all cases, you'll need some options to make a useful test.
  75. The most important options are <code class="option">-c</code> (number of clients),
  76. <code class="option">-t</code> (number of transactions), <code class="option">-T</code> (time limit),
  77. and <code class="option">-f</code> (specify a custom script file).
  78. See below for a full list.
  79. </p></div><div class="refsect1" id="id-1.9.4.10.6"><h2>Options</h2><p>
  80. The following is divided into three subsections. Different options are
  81. used during database initialization and while running benchmarks, but some
  82. options are useful in both cases.
  83. </p><div class="refsect2" id="PGBENCH-INIT-OPTIONS"><h3>Initialization Options</h3><p>
  84. <span class="application">pgbench</span> accepts the following command-line
  85. initialization arguments:
  86. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-i</code><br /></span><span class="term"><code class="option">--initialize</code></span></dt><dd><p>
  87. Required to invoke initialization mode.
  88. </p></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>init_steps</code></em></code><br /></span><span class="term"><code class="option">--init-steps=<em class="replaceable"><code>init_steps</code></em></code></span></dt><dd><p>
  89. Perform just a selected set of the normal initialization steps.
  90. <em class="replaceable"><code>init_steps</code></em> specifies the
  91. initialization steps to be performed, using one character per step.
  92. Each step is invoked in the specified order.
  93. The default is <code class="literal">dtgvp</code>.
  94. The available steps are:
  95. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">d</code> (Drop)</span></dt><dd><p>
  96. Drop any existing <span class="application">pgbench</span> tables.
  97. </p></dd><dt><span class="term"><code class="literal">t</code> (create Tables)</span></dt><dd><p>
  98. Create the tables used by the
  99. standard <span class="application">pgbench</span> scenario, namely
  100. <code class="structname">pgbench_accounts</code>,
  101. <code class="structname">pgbench_branches</code>,
  102. <code class="structname">pgbench_history</code>, and
  103. <code class="structname">pgbench_tellers</code>.
  104. </p></dd><dt><span class="term"><code class="literal">g</code> (Generate data)</span></dt><dd><p>
  105. Generate data and load it into the standard tables,
  106. replacing any data already present.
  107. </p></dd><dt><span class="term"><code class="literal">v</code> (Vacuum)</span></dt><dd><p>
  108. Invoke <code class="command">VACUUM</code> on the standard tables.
  109. </p></dd><dt><span class="term"><code class="literal">p</code> (create Primary keys)</span></dt><dd><p>
  110. Create primary key indexes on the standard tables.
  111. </p></dd><dt><span class="term"><code class="literal">f</code> (create Foreign keys)</span></dt><dd><p>
  112. Create foreign key constraints between the standard tables.
  113. (Note that this step is not performed by default.)
  114. </p></dd></dl></div><p>
  115. </p></dd><dt><span class="term"><code class="option">-F</code> <em class="replaceable"><code>fillfactor</code></em><br /></span><span class="term"><code class="option">--fillfactor=</code><em class="replaceable"><code>fillfactor</code></em></span></dt><dd><p>
  116. Create the <code class="structname">pgbench_accounts</code>,
  117. <code class="structname">pgbench_tellers</code> and
  118. <code class="structname">pgbench_branches</code> tables with the given fillfactor.
  119. Default is 100.
  120. </p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-vacuum</code></span></dt><dd><p>
  121. Perform no vacuuming during initialization.
  122. (This option suppresses the <code class="literal">v</code> initialization step,
  123. even if it was specified in <code class="option">-I</code>.)
  124. </p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
  125. Switch logging to quiet mode, producing only one progress message per 5
  126. seconds. The default logging prints one message each 100000 rows, which
  127. often outputs many lines per second (especially on good hardware).
  128. </p></dd><dt><span class="term"><code class="option">-s</code> <em class="replaceable"><code>scale_factor</code></em><br /></span><span class="term"><code class="option">--scale=</code><em class="replaceable"><code>scale_factor</code></em></span></dt><dd><p>
  129. Multiply the number of rows generated by the scale factor.
  130. For example, <code class="literal">-s 100</code> will create 10,000,000 rows
  131. in the <code class="structname">pgbench_accounts</code> table. Default is 1.
  132. When the scale is 20,000 or larger, the columns used to
  133. hold account identifiers (<code class="structfield">aid</code> columns)
  134. will switch to using larger integers (<code class="type">bigint</code>),
  135. in order to be big enough to hold the range of account
  136. identifiers.
  137. </p></dd><dt><span class="term"><code class="option">--foreign-keys</code></span></dt><dd><p>
  138. Create foreign key constraints between the standard tables.
  139. (This option adds the <code class="literal">f</code> step to the initialization
  140. step sequence, if it is not already present.)
  141. </p></dd><dt><span class="term"><code class="option">--index-tablespace=<em class="replaceable"><code>index_tablespace</code></em></code></span></dt><dd><p>
  142. Create indexes in the specified tablespace, rather than the default
  143. tablespace.
  144. </p></dd><dt><span class="term"><code class="option">--tablespace=<em class="replaceable"><code>tablespace</code></em></code></span></dt><dd><p>
  145. Create tables in the specified tablespace, rather than the default
  146. tablespace.
  147. </p></dd><dt><span class="term"><code class="option">--unlogged-tables</code></span></dt><dd><p>
  148. Create all tables as unlogged tables, rather than permanent tables.
  149. </p></dd></dl></div><p>
  150. </p></div><div class="refsect2" id="PGBENCH-RUN-OPTIONS"><h3>Benchmarking Options</h3><p>
  151. <span class="application">pgbench</span> accepts the following command-line
  152. benchmarking arguments:
  153. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-b</code> <em class="replaceable"><code>scriptname[@weight]</code></em><br /></span><span class="term"><code class="option">--builtin</code>=<em class="replaceable"><code>scriptname[@weight]</code></em></span></dt><dd><p>
  154. Add the specified built-in script to the list of executed scripts.
  155. An optional integer weight after <code class="literal">@</code> allows to adjust the
  156. probability of drawing the script. If not specified, it is set to 1.
  157. Available built-in scripts are: <code class="literal">tpcb-like</code>,
  158. <code class="literal">simple-update</code> and <code class="literal">select-only</code>.
  159. Unambiguous prefixes of built-in names are accepted.
  160. With special name <code class="literal">list</code>, show the list of built-in scripts
  161. and exit immediately.
  162. </p></dd><dt><span class="term"><code class="option">-c</code> <em class="replaceable"><code>clients</code></em><br /></span><span class="term"><code class="option">--client=</code><em class="replaceable"><code>clients</code></em></span></dt><dd><p>
  163. Number of clients simulated, that is, number of concurrent database
  164. sessions. Default is 1.
  165. </p></dd><dt><span class="term"><code class="option">-C</code><br /></span><span class="term"><code class="option">--connect</code></span></dt><dd><p>
  166. Establish a new connection for each transaction, rather than
  167. doing it just once per client session.
  168. This is useful to measure the connection overhead.
  169. </p></dd><dt><span class="term"><code class="option">-d</code><br /></span><span class="term"><code class="option">--debug</code></span></dt><dd><p>
  170. Print debugging output.
  171. </p></dd><dt><span class="term"><code class="option">-D</code> <em class="replaceable"><code>varname</code></em><code class="literal">=</code><em class="replaceable"><code>value</code></em><br /></span><span class="term"><code class="option">--define=</code><em class="replaceable"><code>varname</code></em><code class="literal">=</code><em class="replaceable"><code>value</code></em></span></dt><dd><p>
  172. Define a variable for use by a custom script (see below).
  173. Multiple <code class="option">-D</code> options are allowed.
  174. </p></dd><dt><span class="term"><code class="option">-f</code> <em class="replaceable"><code>filename[@weight]</code></em><br /></span><span class="term"><code class="option">--file=</code><em class="replaceable"><code>filename[@weight]</code></em></span></dt><dd><p>
  175. Add a transaction script read from <em class="replaceable"><code>filename</code></em> to
  176. the list of executed scripts.
  177. An optional integer weight after <code class="literal">@</code> allows to adjust the
  178. probability of drawing the test.
  179. See below for details.
  180. </p></dd><dt><span class="term"><code class="option">-j</code> <em class="replaceable"><code>threads</code></em><br /></span><span class="term"><code class="option">--jobs=</code><em class="replaceable"><code>threads</code></em></span></dt><dd><p>
  181. Number of worker threads within <span class="application">pgbench</span>.
  182. Using more than one thread can be helpful on multi-CPU machines.
  183. Clients are distributed as evenly as possible among available threads.
  184. Default is 1.
  185. </p></dd><dt><span class="term"><code class="option">-l</code><br /></span><span class="term"><code class="option">--log</code></span></dt><dd><p>
  186. Write information about each transaction to a log file.
  187. See below for details.
  188. </p></dd><dt><span class="term"><code class="option">-L</code> <em class="replaceable"><code>limit</code></em><br /></span><span class="term"><code class="option">--latency-limit=</code><em class="replaceable"><code>limit</code></em></span></dt><dd><p>
  189. Transactions that last more than <em class="replaceable"><code>limit</code></em> milliseconds
  190. are counted and reported separately, as <em class="firstterm">late</em>.
  191. </p><p>
  192. When throttling is used (<code class="option">--rate=...</code>), transactions that
  193. lag behind schedule by more than <em class="replaceable"><code>limit</code></em> ms, and thus
  194. have no hope of meeting the latency limit, are not sent to the server
  195. at all. They are counted and reported separately as
  196. <em class="firstterm">skipped</em>.
  197. </p></dd><dt><span class="term"><code class="option">-M</code> <em class="replaceable"><code>querymode</code></em><br /></span><span class="term"><code class="option">--protocol=</code><em class="replaceable"><code>querymode</code></em></span></dt><dd><p>
  198. Protocol to use for submitting queries to the server:
  199. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><code class="literal">simple</code>: use simple query protocol.</p></li><li class="listitem"><p><code class="literal">extended</code>: use extended query protocol.</p></li><li class="listitem"><p><code class="literal">prepared</code>: use extended query protocol with prepared statements.</p></li></ul></div><p>
  200. In the <code class="literal">prepared</code> mode, <span class="application">pgbench</span>
  201. reuses the parse analysis result starting from the second query
  202. iteration, so <span class="application">pgbench</span> runs faster
  203. than in other modes.
  204. </p><p>
  205. The default is simple query protocol. (See <a class="xref" href="protocol.html" title="Chapter 52. Frontend/Backend Protocol">Chapter 52</a>
  206. for more information.)
  207. </p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--no-vacuum</code></span></dt><dd><p>
  208. Perform no vacuuming before running the test.
  209. This option is <span class="emphasis"><em>necessary</em></span>
  210. if you are running a custom test scenario that does not include
  211. the standard tables <code class="structname">pgbench_accounts</code>,
  212. <code class="structname">pgbench_branches</code>, <code class="structname">pgbench_history</code>, and
  213. <code class="structname">pgbench_tellers</code>.
  214. </p></dd><dt><span class="term"><code class="option">-N</code><br /></span><span class="term"><code class="option">--skip-some-updates</code></span></dt><dd><p>
  215. Run built-in simple-update script.
  216. Shorthand for <code class="option">-b simple-update</code>.
  217. </p></dd><dt><span class="term"><code class="option">-P</code> <em class="replaceable"><code>sec</code></em><br /></span><span class="term"><code class="option">--progress=</code><em class="replaceable"><code>sec</code></em></span></dt><dd><p>
  218. Show progress report every <em class="replaceable"><code>sec</code></em> seconds. The report
  219. includes the time since the beginning of the run, the TPS since the
  220. last report, and the transaction latency average and standard
  221. deviation since the last report. Under throttling (<code class="option">-R</code>),
  222. the latency is computed with respect to the transaction scheduled
  223. start time, not the actual transaction beginning time, thus it also
  224. includes the average schedule lag time.
  225. </p></dd><dt><span class="term"><code class="option">-r</code><br /></span><span class="term"><code class="option">--report-latencies</code></span></dt><dd><p>
  226. Report the average per-statement latency (execution time from the
  227. perspective of the client) of each command after the benchmark
  228. finishes. See below for details.
  229. </p></dd><dt><span class="term"><code class="option">-R</code> <em class="replaceable"><code>rate</code></em><br /></span><span class="term"><code class="option">--rate=</code><em class="replaceable"><code>rate</code></em></span></dt><dd><p>
  230. Execute transactions targeting the specified rate instead of running
  231. as fast as possible (the default). The rate is given in transactions
  232. per second. If the targeted rate is above the maximum possible rate,
  233. the rate limit won't impact the results.
  234. </p><p>
  235. The rate is targeted by starting transactions along a
  236. Poisson-distributed schedule time line. The expected start time
  237. schedule moves forward based on when the client first started, not
  238. when the previous transaction ended. That approach means that when
  239. transactions go past their original scheduled end time, it is
  240. possible for later ones to catch up again.
  241. </p><p>
  242. When throttling is active, the transaction latency reported at the
  243. end of the run is calculated from the scheduled start times, so it
  244. includes the time each transaction had to wait for the previous
  245. transaction to finish. The wait time is called the schedule lag time,
  246. and its average and maximum are also reported separately. The
  247. transaction latency with respect to the actual transaction start time,
  248. i.e. the time spent executing the transaction in the database, can be
  249. computed by subtracting the schedule lag time from the reported
  250. latency.
  251. </p><p>
  252. If <code class="option">--latency-limit</code> is used together with <code class="option">--rate</code>,
  253. a transaction can lag behind so much that it is already over the
  254. latency limit when the previous transaction ends, because the latency
  255. is calculated from the scheduled start time. Such transactions are
  256. not sent to the server, but are skipped altogether and counted
  257. separately.
  258. </p><p>
  259. A high schedule lag time is an indication that the system cannot
  260. process transactions at the specified rate, with the chosen number of
  261. clients and threads. When the average transaction execution time is
  262. longer than the scheduled interval between each transaction, each
  263. successive transaction will fall further behind, and the schedule lag
  264. time will keep increasing the longer the test run is. When that
  265. happens, you will have to reduce the specified transaction rate.
  266. </p></dd><dt><span class="term"><code class="option">-s</code> <em class="replaceable"><code>scale_factor</code></em><br /></span><span class="term"><code class="option">--scale=</code><em class="replaceable"><code>scale_factor</code></em></span></dt><dd><p>
  267. Report the specified scale factor in <span class="application">pgbench</span>'s
  268. output. With the built-in tests, this is not necessary; the
  269. correct scale factor will be detected by counting the number of
  270. rows in the <code class="structname">pgbench_branches</code> table.
  271. However, when testing only custom benchmarks (<code class="option">-f</code> option),
  272. the scale factor will be reported as 1 unless this option is used.
  273. </p></dd><dt><span class="term"><code class="option">-S</code><br /></span><span class="term"><code class="option">--select-only</code></span></dt><dd><p>
  274. Run built-in select-only script.
  275. Shorthand for <code class="option">-b select-only</code>.
  276. </p></dd><dt><span class="term"><code class="option">-t</code> <em class="replaceable"><code>transactions</code></em><br /></span><span class="term"><code class="option">--transactions=</code><em class="replaceable"><code>transactions</code></em></span></dt><dd><p>
  277. Number of transactions each client runs. Default is 10.
  278. </p></dd><dt><span class="term"><code class="option">-T</code> <em class="replaceable"><code>seconds</code></em><br /></span><span class="term"><code class="option">--time=</code><em class="replaceable"><code>seconds</code></em></span></dt><dd><p>
  279. Run the test for this many seconds, rather than a fixed number of
  280. transactions per client. <code class="option">-t</code> and
  281. <code class="option">-T</code> are mutually exclusive.
  282. </p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--vacuum-all</code></span></dt><dd><p>
  283. Vacuum all four standard tables before running the test.
  284. With neither <code class="option">-n</code> nor <code class="option">-v</code>, <span class="application">pgbench</span> will vacuum the
  285. <code class="structname">pgbench_tellers</code> and <code class="structname">pgbench_branches</code>
  286. tables, and will truncate <code class="structname">pgbench_history</code>.
  287. </p></dd><dt><span class="term"><code class="option">--aggregate-interval=<em class="replaceable"><code>seconds</code></em></code></span></dt><dd><p>
  288. Length of aggregation interval (in seconds). May be used only
  289. with <code class="option">-l</code> option. With this option, the log contains
  290. per-interval summary data, as described below.
  291. </p></dd><dt><span class="term"><code class="option">--log-prefix=<em class="replaceable"><code>prefix</code></em></code></span></dt><dd><p>
  292. Set the filename prefix for the log files created by
  293. <code class="option">--log</code>. The default is <code class="literal">pgbench_log</code>.
  294. </p></dd><dt><span class="term"><code class="option">--progress-timestamp</code></span></dt><dd><p>
  295. When showing progress (option <code class="option">-P</code>), use a timestamp
  296. (Unix epoch) instead of the number of seconds since the
  297. beginning of the run. The unit is in seconds, with millisecond
  298. precision after the dot.
  299. This helps compare logs generated by various tools.
  300. </p></dd><dt><span class="term"><code class="option">--random-seed=</code><em class="replaceable"><code>SEED</code></em></span></dt><dd><p>
  301. Set random generator seed. Seeds the system random number generator,
  302. which then produces a sequence of initial generator states, one for
  303. each thread.
  304. Values for <em class="replaceable"><code>SEED</code></em> may be:
  305. <code class="literal">time</code> (the default, the seed is based on the current time),
  306. <code class="literal">rand</code> (use a strong random source, failing if none
  307. is available), or an unsigned decimal integer value.
  308. The random generator is invoked explicitly from a pgbench script
  309. (<code class="literal">random...</code> functions) or implicitly (for instance option
  310. <code class="option">--rate</code> uses it to schedule transactions).
  311. When explicitly set, the value used for seeding is shown on the terminal.
  312. Any value allowed for <em class="replaceable"><code>SEED</code></em> may also be
  313. provided through the environment variable
  314. <code class="literal">PGBENCH_RANDOM_SEED</code>.
  315. To ensure that the provided seed impacts all possible uses, put this option
  316. first or use the environment variable.
  317. </p><p>
  318. Setting the seed explicitly allows to reproduce a <code class="command">pgbench</code>
  319. run exactly, as far as random numbers are concerned.
  320. As the random state is managed per thread, this means the exact same
  321. <code class="command">pgbench</code> run for an identical invocation if there is one
  322. client per thread and there are no external or data dependencies.
  323. From a statistical viewpoint reproducing runs exactly is a bad idea because
  324. it can hide the performance variability or improve performance unduly,
  325. e.g. by hitting the same pages as a previous run.
  326. However, it may also be of great help for debugging, for instance
  327. re-running a tricky case which leads to an error.
  328. Use wisely.
  329. </p></dd><dt><span class="term"><code class="option">--sampling-rate=<em class="replaceable"><code>rate</code></em></code></span></dt><dd><p>
  330. Sampling rate, used when writing data into the log, to reduce the
  331. amount of log generated. If this option is given, only the specified
  332. fraction of transactions are logged. 1.0 means all transactions will
  333. be logged, 0.05 means only 5% of the transactions will be logged.
  334. </p><p>
  335. Remember to take the sampling rate into account when processing the
  336. log file. For example, when computing TPS values, you need to multiply
  337. the numbers accordingly (e.g. with 0.01 sample rate, you'll only get
  338. 1/100 of the actual TPS).
  339. </p></dd></dl></div><p>
  340. </p></div><div class="refsect2" id="PGBENCH-COMMON-OPTIONS"><h3>Common Options</h3><p>
  341. <span class="application">pgbench</span> accepts the following command-line
  342. common arguments:
  343. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h</code> <em class="replaceable"><code>hostname</code></em><br /></span><span class="term"><code class="option">--host=</code><em class="replaceable"><code>hostname</code></em></span></dt><dd><p>
  344. The database server's host name
  345. </p></dd><dt><span class="term"><code class="option">-p</code> <em class="replaceable"><code>port</code></em><br /></span><span class="term"><code class="option">--port=</code><em class="replaceable"><code>port</code></em></span></dt><dd><p>
  346. The database server's port number
  347. </p></dd><dt><span class="term"><code class="option">-U</code> <em class="replaceable"><code>login</code></em><br /></span><span class="term"><code class="option">--username=</code><em class="replaceable"><code>login</code></em></span></dt><dd><p>
  348. The user name to connect as
  349. </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
  350. Print the <span class="application">pgbench</span> version and exit.
  351. </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
  352. Show help about <span class="application">pgbench</span> command line
  353. arguments, and exit.
  354. </p></dd></dl></div><p>
  355. </p></div></div><div class="refsect1" id="id-1.9.4.10.7"><h2>Exit Status</h2><p>
  356. A successful run will exit with status 0. Exit status 1 indicates static
  357. problems such as invalid command-line options. Errors during the run such
  358. as database errors or problems in the script will result in exit status 2.
  359. In the latter case, <span class="application">pgbench</span> will print partial
  360. results.
  361. </p></div><div class="refsect1" id="id-1.9.4.10.8"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
  362. Default connection parameters.
  363. </p></dd></dl></div><p>
  364. This utility, like most other <span class="productname">PostgreSQL</span> utilities,
  365. uses the environment variables supported by <span class="application">libpq</span>
  366. (see <a class="xref" href="libpq-envars.html" title="33.14. Environment Variables">Section 33.14</a>).
  367. </p></div><div class="refsect1" id="id-1.9.4.10.9"><h2>Notes</h2><div class="refsect2" id="id-1.9.4.10.9.2"><h3>What Is the <span class="quote">“<span class="quote">Transaction</span>”</span> Actually Performed in <span class="application">pgbench</span>?</h3><p>
  368. <span class="application">pgbench</span> executes test scripts chosen randomly
  369. from a specified list.
  370. They include built-in scripts with <code class="option">-b</code> and
  371. user-provided custom scripts with <code class="option">-f</code>.
  372. Each script may be given a relative weight specified after a
  373. <code class="literal">@</code> so as to change its drawing probability.
  374. The default weight is <code class="literal">1</code>.
  375. Scripts with a weight of <code class="literal">0</code> are ignored.
  376. </p><p>
  377. The default built-in transaction script (also invoked with <code class="option">-b tpcb-like</code>)
  378. issues seven commands per transaction over randomly chosen <code class="literal">aid</code>,
  379. <code class="literal">tid</code>, <code class="literal">bid</code> and <code class="literal">delta</code>.
  380. The scenario is inspired by the TPC-B benchmark, but is not actually TPC-B,
  381. hence the name.
  382. </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><code class="literal">BEGIN;</code></p></li><li class="listitem"><p><code class="literal">UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;</code></p></li><li class="listitem"><p><code class="literal">SELECT abalance FROM pgbench_accounts WHERE aid = :aid;</code></p></li><li class="listitem"><p><code class="literal">UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;</code></p></li><li class="listitem"><p><code class="literal">UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;</code></p></li><li class="listitem"><p><code class="literal">INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);</code></p></li><li class="listitem"><p><code class="literal">END;</code></p></li></ol></div><p>
  383. If you select the <code class="literal">simple-update</code> built-in (also <code class="option">-N</code>),
  384. steps 4 and 5 aren't included in the transaction.
  385. This will avoid update contention on these tables, but
  386. it makes the test case even less like TPC-B.
  387. </p><p>
  388. If you select the <code class="literal">select-only</code> built-in (also <code class="option">-S</code>),
  389. only the <code class="command">SELECT</code> is issued.
  390. </p></div><div class="refsect2" id="id-1.9.4.10.9.3"><h3>Custom Scripts</h3><p>
  391. <span class="application">pgbench</span> has support for running custom
  392. benchmark scenarios by replacing the default transaction script
  393. (described above) with a transaction script read from a file
  394. (<code class="option">-f</code> option). In this case a <span class="quote">“<span class="quote">transaction</span>”</span>
  395. counts as one execution of a script file.
  396. </p><p>
  397. A script file contains one or more SQL commands terminated by
  398. semicolons. Empty lines and lines beginning with
  399. <code class="literal">--</code> are ignored. Script files can also contain
  400. <span class="quote">“<span class="quote">meta commands</span>”</span>, which are interpreted by <span class="application">pgbench</span>
  401. itself, as described below.
  402. </p><div class="note"><h3 class="title">Note</h3><p>
  403. Before <span class="productname">PostgreSQL</span> 9.6, SQL commands in script files
  404. were terminated by newlines, and so they could not be continued across
  405. lines. Now a semicolon is <span class="emphasis"><em>required</em></span> to separate consecutive
  406. SQL commands (though a SQL command does not need one if it is followed
  407. by a meta command). If you need to create a script file that works with
  408. both old and new versions of <span class="application">pgbench</span>, be sure to write
  409. each SQL command on a single line ending with a semicolon.
  410. </p></div><p>
  411. There is a simple variable-substitution facility for script files.
  412. Variable names must consist of letters (including non-Latin letters),
  413. digits, and underscores.
  414. Variables can be set by the command-line <code class="option">-D</code> option,
  415. explained above, or by the meta commands explained below.
  416. In addition to any variables preset by <code class="option">-D</code> command-line options,
  417. there are a few variables that are preset automatically, listed in
  418. <a class="xref" href="pgbench.html#PGBENCH-AUTOMATIC-VARIABLES" title="Table 257. Automatic Variables">Table 257</a>. A value specified for these
  419. variables using <code class="option">-D</code> takes precedence over the automatic presets.
  420. Once set, a variable's
  421. value can be inserted into a SQL command by writing
  422. <code class="literal">:</code><em class="replaceable"><code>variablename</code></em>. When running more than
  423. one client session, each session has its own set of variables.
  424. <span class="application">pgbench</span> supports up to 255 variable uses in one
  425. statement.
  426. </p><div class="table" id="PGBENCH-AUTOMATIC-VARIABLES"><p class="title"><strong>Table 257. Automatic Variables</strong></p><div class="table-contents"><table class="table" summary="Automatic Variables" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Variable</th><th>Description</th></tr></thead><tbody><tr><td> <code class="literal">client_id</code> </td><td>unique number identifying the client session (starts from zero)</td></tr><tr><td> <code class="literal">default_seed</code> </td><td>seed used in hash functions by default</td></tr><tr><td> <code class="literal">random_seed</code> </td><td>random generator seed (unless overwritten with <code class="option">-D</code>)</td></tr><tr><td> <code class="literal">scale</code> </td><td>current scale factor</td></tr></tbody></table></div></div><br class="table-break" /><p>
  427. Script file meta commands begin with a backslash (<code class="literal">\</code>) and
  428. normally extend to the end of the line, although they can be continued
  429. to additional lines by writing backslash-return.
  430. Arguments to a meta command are separated by white space.
  431. These meta commands are supported:
  432. </p><div class="variablelist"><dl class="variablelist"><dt id="PGBENCH-METACOMMAND-GSET"><span class="term">
  433. <code class="literal">\gset [<em class="replaceable"><code>prefix</code></em>]</code>
  434. </span></dt><dd><p>
  435. This command may be used to end SQL queries, taking the place of the
  436. terminating semicolon (<code class="literal">;</code>).
  437. </p><p>
  438. When this command is used, the preceding SQL query is expected to
  439. return one row, the columns of which are stored into variables named after
  440. column names, and prefixed with <em class="replaceable"><code>prefix</code></em> if provided.
  441. </p><p>
  442. The following example puts the final account balance from the first query
  443. into variable <em class="replaceable"><code>abalance</code></em>, and fills variables
  444. <em class="replaceable"><code>p_two</code></em> and <em class="replaceable"><code>p_three</code></em>
  445. with integers from the third query.
  446. The result of the second query is discarded.
  447. </p><pre class="programlisting">
  448. UPDATE pgbench_accounts
  449. SET abalance = abalance + :delta
  450. WHERE aid = :aid
  451. RETURNING abalance \gset
  452. -- compound of two queries
  453. SELECT 1 \;
  454. SELECT 2 AS two, 3 AS three \gset p_
  455. </pre><p>
  456. </p></dd><dt><span class="term"><code class="literal">\if</code> <em class="replaceable"><code>expression</code></em><br /></span><span class="term"><code class="literal">\elif</code> <em class="replaceable"><code>expression</code></em><br /></span><span class="term"><code class="literal">\else</code><br /></span><span class="term"><code class="literal">\endif</code></span></dt><dd><p>
  457. This group of commands implements nestable conditional blocks,
  458. similarly to <code class="literal">psql</code>'s <a class="xref" href="app-psql.html#PSQL-METACOMMAND-IF"><code class="literal">\if</code> <em class="replaceable"><code>expression</code></em></a>.
  459. Conditional expressions are identical to those with <code class="literal">\set</code>,
  460. with non-zero values interpreted as true.
  461. </p></dd><dt id="PGBENCH-METACOMMAND-SET"><span class="term">
  462. <code class="literal">\set <em class="replaceable"><code>varname</code></em> <em class="replaceable"><code>expression</code></em></code>
  463. </span></dt><dd><p>
  464. Sets variable <em class="replaceable"><code>varname</code></em> to a value calculated
  465. from <em class="replaceable"><code>expression</code></em>.
  466. The expression may contain the <code class="literal">NULL</code> constant,
  467. Boolean constants <code class="literal">TRUE</code> and <code class="literal">FALSE</code>,
  468. integer constants such as <code class="literal">5432</code>,
  469. double constants such as <code class="literal">3.14159</code>,
  470. references to variables <code class="literal">:</code><em class="replaceable"><code>variablename</code></em>,
  471. <a class="link" href="pgbench.html#PGBENCH-BUILTIN-OPERATORS" title="Built-in Operators">operators</a>
  472. with their usual SQL precedence and associativity,
  473. <a class="link" href="pgbench.html#PGBENCH-BUILTIN-FUNCTIONS" title="Built-In Functions">function calls</a>,
  474. SQL <a class="link" href="functions-conditional.html#FUNCTIONS-CASE" title="9.17.1. CASE"><code class="token">CASE</code> generic conditional
  475. expressions</a> and parentheses.
  476. </p><p>
  477. Functions and most operators return <code class="literal">NULL</code> on
  478. <code class="literal">NULL</code> input.
  479. </p><p>
  480. For conditional purposes, non zero numerical values are
  481. <code class="literal">TRUE</code>, zero numerical values and <code class="literal">NULL</code>
  482. are <code class="literal">FALSE</code>.
  483. </p><p>
  484. Too large or small integer and double constants, as well as
  485. integer arithmetic operators (<code class="literal">+</code>,
  486. <code class="literal">-</code>, <code class="literal">*</code> and <code class="literal">/</code>)
  487. raise errors on overflows.
  488. </p><p>
  489. When no final <code class="token">ELSE</code> clause is provided to a
  490. <code class="token">CASE</code>, the default value is <code class="literal">NULL</code>.
  491. </p><p>
  492. Examples:
  493. </p><pre class="programlisting">
  494. \set ntellers 10 * :scale
  495. \set aid (1021 * random(1, 100000 * :scale)) % \
  496. (100000 * :scale) + 1
  497. \set divx CASE WHEN :x &lt;&gt; 0 THEN :y/:x ELSE NULL END
  498. </pre></dd><dt><span class="term">
  499. <code class="literal">\sleep <em class="replaceable"><code>number</code></em> [ us | ms | s ]</code>
  500. </span></dt><dd><p>
  501. Causes script execution to sleep for the specified duration in
  502. microseconds (<code class="literal">us</code>), milliseconds (<code class="literal">ms</code>) or seconds
  503. (<code class="literal">s</code>). If the unit is omitted then seconds are the default.
  504. <em class="replaceable"><code>number</code></em> can be either an integer constant or a
  505. <code class="literal">:</code><em class="replaceable"><code>variablename</code></em> reference to a variable
  506. having an integer value.
  507. </p><p>
  508. Example:
  509. </p><pre class="programlisting">
  510. \sleep 10 ms
  511. </pre></dd><dt><span class="term">
  512. <code class="literal">\setshell <em class="replaceable"><code>varname</code></em> <em class="replaceable"><code>command</code></em> [ <em class="replaceable"><code>argument</code></em> ... ]</code>
  513. </span></dt><dd><p>
  514. Sets variable <em class="replaceable"><code>varname</code></em> to the result of the shell command
  515. <em class="replaceable"><code>command</code></em> with the given <em class="replaceable"><code>argument</code></em>(s).
  516. The command must return an integer value through its standard output.
  517. </p><p>
  518. <em class="replaceable"><code>command</code></em> and each <em class="replaceable"><code>argument</code></em> can be either
  519. a text constant or a <code class="literal">:</code><em class="replaceable"><code>variablename</code></em> reference
  520. to a variable. If you want to use an <em class="replaceable"><code>argument</code></em> starting
  521. with a colon, write an additional colon at the beginning of
  522. <em class="replaceable"><code>argument</code></em>.
  523. </p><p>
  524. Example:
  525. </p><pre class="programlisting">
  526. \setshell variable_to_be_assigned command literal_argument :variable ::literal_starting_with_colon
  527. </pre></dd><dt><span class="term">
  528. <code class="literal">\shell <em class="replaceable"><code>command</code></em> [ <em class="replaceable"><code>argument</code></em> ... ]</code>
  529. </span></dt><dd><p>
  530. Same as <code class="literal">\setshell</code>, but the result of the command
  531. is discarded.
  532. </p><p>
  533. Example:
  534. </p><pre class="programlisting">
  535. \shell command literal_argument :variable ::literal_starting_with_colon
  536. </pre></dd></dl></div></div><div class="refsect2" id="PGBENCH-BUILTIN-OPERATORS"><h3>Built-in Operators</h3><p>
  537. The arithmetic, bitwise, comparison and logical operators listed in
  538. <a class="xref" href="pgbench.html#PGBENCH-OPERATORS" title="Table 258. pgbench Operators by Increasing Precedence">Table 258</a> are built into <span class="application">pgbench</span>
  539. and may be used in expressions appearing in
  540. <a class="link" href="pgbench.html#PGBENCH-METACOMMAND-SET"><code class="literal">\set</code></a>.
  541. </p><div class="table" id="PGBENCH-OPERATORS"><p class="title"><strong>Table 258. pgbench Operators by Increasing Precedence</strong></p><div class="table-contents"><table class="table" summary="pgbench Operators by Increasing Precedence" border="1"><colgroup><col /><col /><col /><col /></colgroup><thead><tr><th>Operator</th><th>Description</th><th>Example</th><th>Result</th></tr></thead><tbody><tr><td><code class="literal">OR</code></td><td>logical or</td><td><code class="literal">5 or 0</code></td><td><code class="literal">TRUE</code></td></tr><tr><td><code class="literal">AND</code></td><td>logical and</td><td><code class="literal">3 and 0</code></td><td><code class="literal">FALSE</code></td></tr><tr><td><code class="literal">NOT</code></td><td>logical not</td><td><code class="literal">not false</code></td><td><code class="literal">TRUE</code></td></tr><tr><td><code class="literal">IS [NOT] (NULL|TRUE|FALSE)</code></td><td>value tests</td><td><code class="literal">1 is null</code></td><td><code class="literal">FALSE</code></td></tr><tr><td><code class="literal">ISNULL|NOTNULL</code></td><td>null tests</td><td><code class="literal">1 notnull</code></td><td><code class="literal">TRUE</code></td></tr><tr><td><code class="literal">=</code></td><td>is equal</td><td><code class="literal">5 = 4</code></td><td><code class="literal">FALSE</code></td></tr><tr><td><code class="literal">&lt;&gt;</code></td><td>is not equal</td><td><code class="literal">5 &lt;&gt; 4</code></td><td><code class="literal">TRUE</code></td></tr><tr><td><code class="literal">!=</code></td><td>is not equal</td><td><code class="literal">5 != 5</code></td><td><code class="literal">FALSE</code></td></tr><tr><td><code class="literal">&lt;</code></td><td>lower than</td><td><code class="literal">5 &lt; 4</code></td><td><code class="literal">FALSE</code></td></tr><tr><td><code class="literal">&lt;=</code></td><td>lower or equal</td><td><code class="literal">5 &lt;= 4</code></td><td><code class="literal">FALSE</code></td></tr><tr><td><code class="literal">&gt;</code></td><td>greater than</td><td><code class="literal">5 &gt; 4</code></td><td><code class="literal">TRUE</code></td></tr><tr><td><code class="literal">&gt;=</code></td><td>greater or equal</td><td><code class="literal">5 &gt;= 4</code></td><td><code class="literal">TRUE</code></td></tr><tr><td><code class="literal">|</code></td><td>integer bitwise OR</td><td><code class="literal">1 | 2</code></td><td><code class="literal">3</code></td></tr><tr><td><code class="literal">#</code></td><td>integer bitwise XOR</td><td><code class="literal">1 # 3</code></td><td><code class="literal">2</code></td></tr><tr><td><code class="literal">&amp;</code></td><td>integer bitwise AND</td><td><code class="literal">1 &amp; 3</code></td><td><code class="literal">1</code></td></tr><tr><td><code class="literal">~</code></td><td>integer bitwise NOT</td><td><code class="literal">~ 1</code></td><td><code class="literal">-2</code></td></tr><tr><td><code class="literal">&lt;&lt;</code></td><td>integer bitwise shift left</td><td><code class="literal">1 &lt;&lt; 2</code></td><td><code class="literal">4</code></td></tr><tr><td><code class="literal">&gt;&gt;</code></td><td>integer bitwise shift right</td><td><code class="literal">8 &gt;&gt; 2</code></td><td><code class="literal">2</code></td></tr><tr><td><code class="literal">+</code></td><td>addition</td><td><code class="literal">5 + 4</code></td><td><code class="literal">9</code></td></tr><tr><td><code class="literal">-</code></td><td>subtraction</td><td><code class="literal">3 - 2.0</code></td><td><code class="literal">1.0</code></td></tr><tr><td><code class="literal">*</code></td><td>multiplication</td><td><code class="literal">5 * 4</code></td><td><code class="literal">20</code></td></tr><tr><td><code class="literal">/</code></td><td>division (integer truncates the results)</td><td><code class="literal">5 / 3</code></td><td><code class="literal">1</code></td></tr><tr><td><code class="literal">%</code></td><td>modulo</td><td><code class="literal">3 % 2</code></td><td><code class="literal">1</code></td></tr><tr><td><code class="literal">-</code></td><td>opposite</td><td><code class="literal">- 2.0</code></td><td><code class="literal">-2.0</code></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="refsect2" id="PGBENCH-BUILTIN-FUNCTIONS"><h3>Built-In Functions</h3><p>
  542. The functions listed in <a class="xref" href="pgbench.html#PGBENCH-FUNCTIONS" title="Table 259. pgbench Functions">Table 259</a> are built
  543. into <span class="application">pgbench</span> and may be used in expressions appearing in
  544. <a class="link" href="pgbench.html#PGBENCH-METACOMMAND-SET"><code class="literal">\set</code></a>.
  545. </p><div class="table" id="PGBENCH-FUNCTIONS"><p class="title"><strong>Table 259. pgbench Functions</strong></p><div class="table-contents"><table class="table" summary="pgbench Functions" border="1"><colgroup><col /><col /><col /><col /><col /></colgroup><thead><tr><th>Function</th><th>Return Type</th><th>Description</th><th>Example</th><th>Result</th></tr></thead><tbody><tr><td><code class="literal"><code class="function">abs(<em class="replaceable"><code>a</code></em>)</code></code></td><td>same as <em class="replaceable"><code>a</code></em></td><td>absolute value</td><td><code class="literal">abs(-17)</code></td><td><code class="literal">17</code></td></tr><tr><td><code class="literal"><code class="function">debug(<em class="replaceable"><code>a</code></em>)</code></code></td><td>same as <em class="replaceable"><code>a</code></em> </td><td>print <em class="replaceable"><code>a</code></em> to <span class="systemitem">stderr</span>,
  546. and return <em class="replaceable"><code>a</code></em></td><td><code class="literal">debug(5432.1)</code></td><td><code class="literal">5432.1</code></td></tr><tr><td><code class="literal"><code class="function">double(<em class="replaceable"><code>i</code></em>)</code></code></td><td>double</td><td>cast to double</td><td><code class="literal">double(5432)</code></td><td><code class="literal">5432.0</code></td></tr><tr><td><code class="literal"><code class="function">exp(<em class="replaceable"><code>x</code></em>)</code></code></td><td>double</td><td>exponential</td><td><code class="literal">exp(1.0)</code></td><td><code class="literal">2.718281828459045</code></td></tr><tr><td><code class="literal"><code class="function">greatest(<em class="replaceable"><code>a</code></em> [, <em class="replaceable"><code>...</code></em> ] )</code></code></td><td>double if any <em class="replaceable"><code>a</code></em> is double, else integer</td><td>largest value among arguments</td><td><code class="literal">greatest(5, 4, 3, 2)</code></td><td><code class="literal">5</code></td></tr><tr><td><code class="literal"><code class="function">hash(<em class="replaceable"><code>a</code></em> [, <em class="replaceable"><code>seed</code></em> ] )</code></code></td><td>integer</td><td>alias for <code class="literal">hash_murmur2()</code></td><td><code class="literal">hash(10, 5432)</code></td><td><code class="literal">-5817877081768721676</code></td></tr><tr><td><code class="literal"><code class="function">hash_fnv1a(<em class="replaceable"><code>a</code></em> [, <em class="replaceable"><code>seed</code></em> ] )</code></code></td><td>integer</td><td><a class="ulink" href="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function" target="_top">FNV-1a hash</a></td><td><code class="literal">hash_fnv1a(10, 5432)</code></td><td><code class="literal">-7793829335365542153</code></td></tr><tr><td><code class="literal"><code class="function">hash_murmur2(<em class="replaceable"><code>a</code></em> [, <em class="replaceable"><code>seed</code></em> ] )</code></code></td><td>integer</td><td><a class="ulink" href="https://en.wikipedia.org/wiki/MurmurHash" target="_top">MurmurHash2 hash</a></td><td><code class="literal">hash_murmur2(10, 5432)</code></td><td><code class="literal">-5817877081768721676</code></td></tr><tr><td><code class="literal"><code class="function">int(<em class="replaceable"><code>x</code></em>)</code></code></td><td>integer</td><td>cast to int</td><td><code class="literal">int(5.4 + 3.8)</code></td><td><code class="literal">9</code></td></tr><tr><td><code class="literal"><code class="function">least(<em class="replaceable"><code>a</code></em> [, <em class="replaceable"><code>...</code></em> ] )</code></code></td><td>double if any <em class="replaceable"><code>a</code></em> is double, else integer</td><td>smallest value among arguments</td><td><code class="literal">least(5, 4, 3, 2.1)</code></td><td><code class="literal">2.1</code></td></tr><tr><td><code class="literal"><code class="function">ln(<em class="replaceable"><code>x</code></em>)</code></code></td><td>double</td><td>natural logarithm</td><td><code class="literal">ln(2.718281828459045)</code></td><td><code class="literal">1.0</code></td></tr><tr><td><code class="literal"><code class="function">mod(<em class="replaceable"><code>i</code></em>, <em class="replaceable"><code>j</code></em>)</code></code></td><td>integer</td><td>modulo</td><td><code class="literal">mod(54, 32)</code></td><td><code class="literal">22</code></td></tr><tr><td><code class="literal"><code class="function">pi()</code></code></td><td>double</td><td>value of the constant PI</td><td><code class="literal">pi()</code></td><td><code class="literal">3.14159265358979323846</code></td></tr><tr><td><code class="literal"><code class="function">pow(<em class="replaceable"><code>x</code></em>, <em class="replaceable"><code>y</code></em>)</code>, <code class="function">power(<em class="replaceable"><code>x</code></em>, <em class="replaceable"><code>y</code></em>)</code></code></td><td>double</td><td>exponentiation</td><td><code class="literal">pow(2.0, 10)</code>, <code class="literal">power(2.0, 10)</code></td><td><code class="literal">1024.0</code></td></tr><tr><td><code class="literal"><code class="function">random(<em class="replaceable"><code>lb</code></em>, <em class="replaceable"><code>ub</code></em>)</code></code></td><td>integer</td><td>uniformly-distributed random integer in <code class="literal">[lb, ub]</code></td><td><code class="literal">random(1, 10)</code></td><td>an integer between <code class="literal">1</code> and <code class="literal">10</code></td></tr><tr><td><code class="literal"><code class="function">random_exponential(<em class="replaceable"><code>lb</code></em>, <em class="replaceable"><code>ub</code></em>, <em class="replaceable"><code>parameter</code></em>)</code></code></td><td>integer</td><td>exponentially-distributed random integer in <code class="literal">[lb, ub]</code>,
  547. see below</td><td><code class="literal">random_exponential(1, 10, 3.0)</code></td><td>an integer between <code class="literal">1</code> and <code class="literal">10</code></td></tr><tr><td><code class="literal"><code class="function">random_gaussian(<em class="replaceable"><code>lb</code></em>, <em class="replaceable"><code>ub</code></em>, <em class="replaceable"><code>parameter</code></em>)</code></code></td><td>integer</td><td>Gaussian-distributed random integer in <code class="literal">[lb, ub]</code>,
  548. see below</td><td><code class="literal">random_gaussian(1, 10, 2.5)</code></td><td>an integer between <code class="literal">1</code> and <code class="literal">10</code></td></tr><tr><td><code class="literal"><code class="function">random_zipfian(<em class="replaceable"><code>lb</code></em>, <em class="replaceable"><code>ub</code></em>, <em class="replaceable"><code>parameter</code></em>)</code></code></td><td>integer</td><td>Zipfian-distributed random integer in <code class="literal">[lb, ub]</code>,
  549. see below</td><td><code class="literal">random_zipfian(1, 10, 1.5)</code></td><td>an integer between <code class="literal">1</code> and <code class="literal">10</code></td></tr><tr><td><code class="literal"><code class="function">sqrt(<em class="replaceable"><code>x</code></em>)</code></code></td><td>double</td><td>square root</td><td><code class="literal">sqrt(2.0)</code></td><td><code class="literal">1.414213562</code></td></tr></tbody></table></div></div><br class="table-break" /><p>
  550. The <code class="literal">random</code> function generates values using a uniform
  551. distribution, that is all the values are drawn within the specified
  552. range with equal probability. The <code class="literal">random_exponential</code>,
  553. <code class="literal">random_gaussian</code> and <code class="literal">random_zipfian</code>
  554. functions require an additional double parameter which determines the precise
  555. shape of the distribution.
  556. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  557. For an exponential distribution, <em class="replaceable"><code>parameter</code></em>
  558. controls the distribution by truncating a quickly-decreasing
  559. exponential distribution at <em class="replaceable"><code>parameter</code></em>, and then
  560. projecting onto integers between the bounds.
  561. To be precise, with
  562. </p><div class="literallayout"><p><br />
  563. f(x) = exp(-parameter * (x - min) / (max - min + 1)) / (1 - exp(-parameter))<br />
  564. </p></div><p>
  565. Then value <em class="replaceable"><code>i</code></em> between <em class="replaceable"><code>min</code></em> and
  566. <em class="replaceable"><code>max</code></em> inclusive is drawn with probability:
  567. <code class="literal">f(i) - f(i + 1)</code>.
  568. </p><p>
  569. Intuitively, the larger the <em class="replaceable"><code>parameter</code></em>, the more
  570. frequently values close to <em class="replaceable"><code>min</code></em> are accessed, and the
  571. less frequently values close to <em class="replaceable"><code>max</code></em> are accessed.
  572. The closer to 0 <em class="replaceable"><code>parameter</code></em> is, the flatter (more
  573. uniform) the access distribution.
  574. A crude approximation of the distribution is that the most frequent 1%
  575. values in the range, close to <em class="replaceable"><code>min</code></em>, are drawn
  576. <em class="replaceable"><code>parameter</code></em>% of the time.
  577. The <em class="replaceable"><code>parameter</code></em> value must be strictly positive.
  578. </p></li><li class="listitem"><p>
  579. For a Gaussian distribution, the interval is mapped onto a standard
  580. normal distribution (the classical bell-shaped Gaussian curve) truncated
  581. at <code class="literal">-parameter</code> on the left and <code class="literal">+parameter</code>
  582. on the right.
  583. Values in the middle of the interval are more likely to be drawn.
  584. To be precise, if <code class="literal">PHI(x)</code> is the cumulative distribution
  585. function of the standard normal distribution, with mean <code class="literal">mu</code>
  586. defined as <code class="literal">(max + min) / 2.0</code>, with
  587. </p><div class="literallayout"><p><br />
  588. f(x) = PHI(2.0 * parameter * (x - mu) / (max - min + 1)) /<br />
  589.        (2.0 * PHI(parameter) - 1)<br />
  590. </p></div><p>
  591. then value <em class="replaceable"><code>i</code></em> between <em class="replaceable"><code>min</code></em> and
  592. <em class="replaceable"><code>max</code></em> inclusive is drawn with probability:
  593. <code class="literal">f(i + 0.5) - f(i - 0.5)</code>.
  594. Intuitively, the larger the <em class="replaceable"><code>parameter</code></em>, the more
  595. frequently values close to the middle of the interval are drawn, and the
  596. less frequently values close to the <em class="replaceable"><code>min</code></em> and
  597. <em class="replaceable"><code>max</code></em> bounds. About 67% of values are drawn from the
  598. middle <code class="literal">1.0 / parameter</code>, that is a relative
  599. <code class="literal">0.5 / parameter</code> around the mean, and 95% in the middle
  600. <code class="literal">2.0 / parameter</code>, that is a relative
  601. <code class="literal">1.0 / parameter</code> around the mean; for instance, if
  602. <em class="replaceable"><code>parameter</code></em> is 4.0, 67% of values are drawn from the
  603. middle quarter (1.0 / 4.0) of the interval (i.e. from
  604. <code class="literal">3.0 / 8.0</code> to <code class="literal">5.0 / 8.0</code>) and 95% from
  605. the middle half (<code class="literal">2.0 / 4.0</code>) of the interval (second and third
  606. quartiles). The minimum allowed <em class="replaceable"><code>parameter</code></em>
  607. value is 2.0.
  608. </p></li><li class="listitem"><p>
  609. <code class="literal">random_zipfian</code> generates a bounded Zipfian
  610. distribution.
  611. <em class="replaceable"><code>parameter</code></em> defines how skewed the distribution
  612. is. The larger the <em class="replaceable"><code>parameter</code></em>, the more
  613. frequently values closer to the beginning of the interval are drawn.
  614. The distribution is such that, assuming the range starts from 1,
  615. the ratio of the probability of drawing <em class="replaceable"><code>k</code></em>
  616. versus drawing <em class="replaceable"><code>k+1</code></em> is
  617. <code class="literal">((<em class="replaceable"><code>k</code></em>+1)/<em class="replaceable"><code>k</code></em>)**<em class="replaceable"><code>parameter</code></em></code>.
  618. For example, <code class="literal">random_zipfian(1, ..., 2.5)</code> produces
  619. the value <code class="literal">1</code> about <code class="literal">(2/1)**2.5 =
  620. 5.66</code> times more frequently than <code class="literal">2</code>, which
  621. itself is produced <code class="literal">(3/2)**2.5 = 2.76</code> times more
  622. frequently than <code class="literal">3</code>, and so on.
  623. </p><p>
  624. <span class="application">pgbench</span>'s implementation is based on
  625. "Non-Uniform Random Variate Generation", Luc Devroye, p. 550-551,
  626. Springer 1986. Due to limitations of that algorithm,
  627. the <em class="replaceable"><code>parameter</code></em> value is restricted to
  628. the range [1.001, 1000].
  629. </p></li></ul></div><p>
  630. Hash functions <code class="literal">hash</code>, <code class="literal">hash_murmur2</code> and
  631. <code class="literal">hash_fnv1a</code> accept an input value and an optional seed parameter.
  632. In case the seed isn't provided the value of <code class="literal">:default_seed</code>
  633. is used, which is initialized randomly unless set by the command-line
  634. <code class="literal">-D</code> option. Hash functions can be used to scatter the
  635. distribution of random functions such as <code class="literal">random_zipfian</code> or
  636. <code class="literal">random_exponential</code>. For instance, the following pgbench
  637. script simulates possible real world workload typical for social media and
  638. blogging platforms where few accounts generate excessive load:
  639. </p><pre class="programlisting">
  640. \set r random_zipfian(0, 100000000, 1.07)
  641. \set k abs(hash(:r)) % 1000000
  642. </pre><p>
  643. In some cases several distinct distributions are needed which don't correlate
  644. with each other and this is when implicit seed parameter comes in handy:
  645. </p><pre class="programlisting">
  646. \set k1 abs(hash(:r, :default_seed + 123)) % 1000000
  647. \set k2 abs(hash(:r, :default_seed + 321)) % 1000000
  648. </pre><p>
  649. </p><p>
  650. As an example, the full definition of the built-in TPC-B-like
  651. transaction is:
  652. </p><pre class="programlisting">
  653. \set aid random(1, 100000 * :scale)
  654. \set bid random(1, 1 * :scale)
  655. \set tid random(1, 10 * :scale)
  656. \set delta random(-5000, 5000)
  657. BEGIN;
  658. UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
  659. SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
  660. UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
  661. UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
  662. INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
  663. END;
  664. </pre><p>
  665. This script allows each iteration of the transaction to reference
  666. different, randomly-chosen rows. (This example also shows why it's
  667. important for each client session to have its own variables —
  668. otherwise they'd not be independently touching different rows.)
  669. </p></div><div class="refsect2" id="id-1.9.4.10.9.6"><h3>Per-Transaction Logging</h3><p>
  670. With the <code class="option">-l</code> option (but without
  671. the <code class="option">--aggregate-interval</code> option),
  672. <span class="application">pgbench</span> writes information about each transaction
  673. to a log file. The log file will be named
  674. <code class="filename"><em class="replaceable"><code>prefix</code></em>.<em class="replaceable"><code>nnn</code></em></code>,
  675. where <em class="replaceable"><code>prefix</code></em> defaults to <code class="literal">pgbench_log</code>, and
  676. <em class="replaceable"><code>nnn</code></em> is the PID of the
  677. <span class="application">pgbench</span> process.
  678. The prefix can be changed by using the <code class="option">--log-prefix</code> option.
  679. If the <code class="option">-j</code> option is 2 or higher, so that there are multiple
  680. worker threads, each will have its own log file. The first worker will
  681. use the same name for its log file as in the standard single worker case.
  682. The additional log files for the other workers will be named
  683. <code class="filename"><em class="replaceable"><code>prefix</code></em>.<em class="replaceable"><code>nnn</code></em>.<em class="replaceable"><code>mmm</code></em></code>,
  684. where <em class="replaceable"><code>mmm</code></em> is a sequential number for each worker starting
  685. with 1.
  686. </p><p>
  687. The format of the log is:
  688. </p><pre class="synopsis">
  689. <em class="replaceable"><code>client_id</code></em> <em class="replaceable"><code>transaction_no</code></em> <em class="replaceable"><code>time</code></em> <em class="replaceable"><code>script_no</code></em> <em class="replaceable"><code>time_epoch</code></em> <em class="replaceable"><code>time_us</code></em> [<span class="optional"> <em class="replaceable"><code>schedule_lag</code></em> </span>]
  690. </pre><p>
  691. where
  692. <em class="replaceable"><code>client_id</code></em> indicates which client session ran the transaction,
  693. <em class="replaceable"><code>transaction_no</code></em> counts how many transactions have been
  694. run by that session,
  695. <em class="replaceable"><code>time</code></em> is the total elapsed transaction time in microseconds,
  696. <em class="replaceable"><code>script_no</code></em> identifies which script file was used (useful when
  697. multiple scripts were specified with <code class="option">-f</code> or <code class="option">-b</code>),
  698. and <em class="replaceable"><code>time_epoch</code></em>/<em class="replaceable"><code>time_us</code></em> are a
  699. Unix-epoch time stamp and an offset
  700. in microseconds (suitable for creating an ISO 8601
  701. time stamp with fractional seconds) showing when
  702. the transaction completed.
  703. The <em class="replaceable"><code>schedule_lag</code></em> field is the difference between the
  704. transaction's scheduled start time, and the time it actually started, in
  705. microseconds. It is only present when the <code class="option">--rate</code> option is used.
  706. When both <code class="option">--rate</code> and <code class="option">--latency-limit</code> are used,
  707. the <em class="replaceable"><code>time</code></em> for a skipped transaction will be reported as
  708. <code class="literal">skipped</code>.
  709. </p><p>
  710. Here is a snippet of a log file generated in a single-client run:
  711. </p><pre class="screen">
  712. 0 199 2241 0 1175850568 995598
  713. 0 200 2465 0 1175850568 998079
  714. 0 201 2513 0 1175850569 608
  715. 0 202 2038 0 1175850569 2663
  716. </pre><p>
  717. Another example with <code class="literal">--rate=100</code>
  718. and <code class="literal">--latency-limit=5</code> (note the additional
  719. <em class="replaceable"><code>schedule_lag</code></em> column):
  720. </p><pre class="screen">
  721. 0 81 4621 0 1412881037 912698 3005
  722. 0 82 6173 0 1412881037 914578 4304
  723. 0 83 skipped 0 1412881037 914578 5217
  724. 0 83 skipped 0 1412881037 914578 5099
  725. 0 83 4722 0 1412881037 916203 3108
  726. 0 84 4142 0 1412881037 918023 2333
  727. 0 85 2465 0 1412881037 919759 740
  728. </pre><p>
  729. In this example, transaction 82 was late, because its latency (6.173 ms) was
  730. over the 5 ms limit. The next two transactions were skipped, because they
  731. were already late before they were even started.
  732. </p><p>
  733. When running a long test on hardware that can handle a lot of transactions,
  734. the log files can become very large. The <code class="option">--sampling-rate</code> option
  735. can be used to log only a random sample of transactions.
  736. </p></div><div class="refsect2" id="id-1.9.4.10.9.7"><h3>Aggregated Logging</h3><p>
  737. With the <code class="option">--aggregate-interval</code> option, a different
  738. format is used for the log files:
  739. </p><pre class="synopsis">
  740. <em class="replaceable"><code>interval_start</code></em> <em class="replaceable"><code>num_transactions</code></em> <em class="replaceable"><code>sum_latency</code></em> <em class="replaceable"><code>sum_latency_2</code></em> <em class="replaceable"><code>min_latency</code></em> <em class="replaceable"><code>max_latency</code></em> [<span class="optional"> <em class="replaceable"><code>sum_lag</code></em> <em class="replaceable"><code>sum_lag_2</code></em> <em class="replaceable"><code>min_lag</code></em> <em class="replaceable"><code>max_lag</code></em> [<span class="optional"> <em class="replaceable"><code>skipped</code></em> </span>] </span>]
  741. </pre><p>
  742. where
  743. <em class="replaceable"><code>interval_start</code></em> is the start of the interval (as a Unix
  744. epoch time stamp),
  745. <em class="replaceable"><code>num_transactions</code></em> is the number of transactions
  746. within the interval,
  747. <em class="replaceable"><code>sum_latency</code></em> is the sum of the transaction
  748. latencies within the interval,
  749. <em class="replaceable"><code>sum_latency_2</code></em> is the sum of squares of the
  750. transaction latencies within the interval,
  751. <em class="replaceable"><code>min_latency</code></em> is the minimum latency within the interval,
  752. and
  753. <em class="replaceable"><code>max_latency</code></em> is the maximum latency within the interval.
  754. The next fields,
  755. <em class="replaceable"><code>sum_lag</code></em>, <em class="replaceable"><code>sum_lag_2</code></em>, <em class="replaceable"><code>min_lag</code></em>,
  756. and <em class="replaceable"><code>max_lag</code></em>, are only present if the <code class="option">--rate</code>
  757. option is used.
  758. They provide statistics about the time each transaction had to wait for the
  759. previous one to finish, i.e. the difference between each transaction's
  760. scheduled start time and the time it actually started.
  761. The very last field, <em class="replaceable"><code>skipped</code></em>,
  762. is only present if the <code class="option">--latency-limit</code> option is used, too.
  763. It counts the number of transactions skipped because they would have
  764. started too late.
  765. Each transaction is counted in the interval when it was committed.
  766. </p><p>
  767. Here is some example output:
  768. </p><pre class="screen">
  769. 1345828501 5601 1542744 483552416 61 2573
  770. 1345828503 7884 1979812 565806736 60 1479
  771. 1345828505 7208 1979422 567277552 59 1391
  772. 1345828507 7685 1980268 569784714 60 1398
  773. 1345828509 7073 1979779 573489941 236 1411
  774. </pre><p>
  775. Notice that while the plain (unaggregated) log file shows which script
  776. was used for each transaction, the aggregated log does not. Therefore if
  777. you need per-script data, you need to aggregate the data on your own.
  778. </p></div><div class="refsect2" id="id-1.9.4.10.9.8"><h3>Per-Statement Latencies</h3><p>
  779. With the <code class="option">-r</code> option, <span class="application">pgbench</span> collects
  780. the elapsed transaction time of each statement executed by every
  781. client. It then reports an average of those values, referred to
  782. as the latency for each statement, after the benchmark has finished.
  783. </p><p>
  784. For the default script, the output will look similar to this:
  785. </p><pre class="screen">
  786. starting vacuum...end.
  787. transaction type: &lt;builtin: TPC-B (sort of)&gt;
  788. scaling factor: 1
  789. query mode: simple
  790. number of clients: 10
  791. number of threads: 1
  792. number of transactions per client: 1000
  793. number of transactions actually processed: 10000/10000
  794. latency average = 15.844 ms
  795. latency stddev = 2.715 ms
  796. tps = 618.764555 (including connections establishing)
  797. tps = 622.977698 (excluding connections establishing)
  798. statement latencies in milliseconds:
  799. 0.002 \set aid random(1, 100000 * :scale)
  800. 0.005 \set bid random(1, 1 * :scale)
  801. 0.002 \set tid random(1, 10 * :scale)
  802. 0.001 \set delta random(-5000, 5000)
  803. 0.326 BEGIN;
  804. 0.603 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
  805. 0.454 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
  806. 5.528 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
  807. 7.335 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
  808. 0.371 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
  809. 1.212 END;
  810. </pre><p>
  811. </p><p>
  812. If multiple script files are specified, the averages are reported
  813. separately for each script file.
  814. </p><p>
  815. Note that collecting the additional timing information needed for
  816. per-statement latency computation adds some overhead. This will slow
  817. average execution speed and lower the computed TPS. The amount
  818. of slowdown varies significantly depending on platform and hardware.
  819. Comparing average TPS values with and without latency reporting enabled
  820. is a good way to measure if the timing overhead is significant.
  821. </p></div><div class="refsect2" id="id-1.9.4.10.9.9"><h3>Good Practices</h3><p>
  822. It is very easy to use <span class="application">pgbench</span> to produce completely
  823. meaningless numbers. Here are some guidelines to help you get useful
  824. results.
  825. </p><p>
  826. In the first place, <span class="emphasis"><em>never</em></span> believe any test that runs
  827. for only a few seconds. Use the <code class="option">-t</code> or <code class="option">-T</code> option
  828. to make the run last at least a few minutes, so as to average out noise.
  829. In some cases you could need hours to get numbers that are reproducible.
  830. It's a good idea to try the test run a few times, to find out if your
  831. numbers are reproducible or not.
  832. </p><p>
  833. For the default TPC-B-like test scenario, the initialization scale factor
  834. (<code class="option">-s</code>) should be at least as large as the largest number of
  835. clients you intend to test (<code class="option">-c</code>); else you'll mostly be
  836. measuring update contention. There are only <code class="option">-s</code> rows in
  837. the <code class="structname">pgbench_branches</code> table, and every transaction wants to
  838. update one of them, so <code class="option">-c</code> values in excess of <code class="option">-s</code>
  839. will undoubtedly result in lots of transactions blocked waiting for
  840. other transactions.
  841. </p><p>
  842. The default test scenario is also quite sensitive to how long it's been
  843. since the tables were initialized: accumulation of dead rows and dead space
  844. in the tables changes the results. To understand the results you must keep
  845. track of the total number of updates and when vacuuming happens. If
  846. autovacuum is enabled it can result in unpredictable changes in measured
  847. performance.
  848. </p><p>
  849. A limitation of <span class="application">pgbench</span> is that it can itself become
  850. the bottleneck when trying to test a large number of client sessions.
  851. This can be alleviated by running <span class="application">pgbench</span> on a different
  852. machine from the database server, although low network latency will be
  853. essential. It might even be useful to run several <span class="application">pgbench</span>
  854. instances concurrently, on several client machines, against the same
  855. database server.
  856. </p></div><div class="refsect2" id="id-1.9.4.10.9.10"><h3>Security</h3><p>
  857. If untrusted users have access to a database that has not adopted a
  858. <a class="link" href="ddl-schemas.html#DDL-SCHEMAS-PATTERNS" title="5.9.6. Usage Patterns">secure schema usage pattern</a>,
  859. do not run <span class="application">pgbench</span> in that
  860. database. <span class="application">pgbench</span> uses unqualified names and
  861. does not manipulate the search path.
  862. </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgbasebackup.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgconfig.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">pg_basebackup </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> pg_config</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1