{"Entry":{"collection":"tool","key":"pgbench","name":"pgbench","aliases":["pgbench"],"metadata":{"aliases":["pgbench"],"category":"Client applications","content_hash":"94a6876ee565cdc95e5811669e9a04b670679beb44ee0376d7af1ce2251784b7","derived_content_hash":"62cd736df6ffd2105935587d38d5a2df16cea579cec67cf0ab4d12977ac2e721","imported_at":"2026-09-30T00:40:34.504058+08:00","name":"pgbench","name_zh":"","slug":"pgbench","summary":"pgbench — run a benchmark test on PostgreSQL"}},"Definition":{"Collection":"tool","Key":"pgbench","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"pgbench","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[{"description":"Default connection parameters.","name":"PGDATABASE PGHOST PGPORT PGUSER"}],"options":[{"description":"Required to invoke initialization mode.","names":["-i","--initialize"],"signature":"-i --initialize"},{"description":"Perform just a selected set of the normal initialization steps. init_steps specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is dtgvp . The available steps are: d (Drop) Drop any existing pgbench tables. t (create Tables) Create the tables used by the standard pgbench scenario, namely pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers . g or G (Generate data, client-side or server-side) Generate data and load it into the standard tables, replacing any data already present. With g (client-side data generation), data is generated in pgbench client and then sent to the server. This uses the client/server bandwidth extensively through a COPY . pgbench uses the FREEZE option to load data into ordinary (non-partition) tables with version 14 or later of PostgreSQL to speed up subsequent VACUUM . Using g causes logging to print one message every 100,000 rows while generating data for all tables. With G (server-side data generation), only small queries are sent from the pgbench client and then data is actually generated in the server. No significant bandwidth is required for this variant, but the server will do more work. Using G causes logging not to print any progress message while generating data. The default initialization behavior uses client-side data generation (equivalent to g ). v (Vacuum) Invoke VACUUM on the standard tables. p (create Primary keys) Create primary key indexes on the standard tables. f (create Foreign keys) Create foreign key constraints between the standard tables. (Note that this step is not performed by default.)","names":["-I init_steps","--init-steps= init_steps"],"signature":"-I init_steps --init-steps= init_steps"},{"description":"Create the pgbench_accounts , pgbench_tellers and pgbench_branches tables with the given fillfactor. Default is 100.","names":["-F","--fillfactor="],"signature":"-F fillfactor --fillfactor= fillfactor"},{"description":"Perform no vacuuming during initialization. (This option suppresses the v initialization step, even if it was specified in -I .)","names":["-n","--no-vacuum"],"signature":"-n --no-vacuum"},{"description":"Switch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware). This setting has no effect if G is specified in -I .","names":["-q","--quiet"],"signature":"-q --quiet"},{"description":"Multiply the number of rows generated by the scale factor. For example, -s 100 will create 10,000,000 rows in the pgbench_accounts table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers ( aid columns) will switch to using larger integers ( bigint ), in order to be big enough to hold the range of account identifiers.","names":["-s","--scale="],"signature":"-s scale_factor --scale= scale_factor"},{"description":"Create foreign key constraints between the standard tables. (This option adds the f step to the initialization step sequence, if it is not already present.)","names":["--foreign-keys"],"signature":"--foreign-keys"},{"description":"Create indexes in the specified tablespace, rather than the default tablespace.","names":["--index-tablespace= index_tablespace"],"signature":"--index-tablespace= index_tablespace"},{"description":"Create a partitioned pgbench_accounts table with NAME method. Expected values are range or hash . This option requires that --partitions is set to non-zero. If unspecified, default is range .","names":["--partition-method= NAME"],"signature":"--partition-method= NAME"},{"description":"Create a partitioned pgbench_accounts table with NUM partitions of nearly equal size for the scaled number of accounts. Default is 0 , meaning no partitioning.","names":["--partitions= NUM"],"signature":"--partitions= NUM"},{"description":"Create tables in the specified tablespace, rather than the default tablespace.","names":["--tablespace= tablespace"],"signature":"--tablespace= tablespace"},{"description":"Create all tables as unlogged tables, rather than permanent tables.","names":["--unlogged-tables"],"signature":"--unlogged-tables"},{"description":"Add the specified built-in script to the list of scripts to be executed. Available built-in scripts are: tpcb-like , simple-update and select-only . Unambiguous prefixes of built-in names are accepted. With the special name list , show the list of built-in scripts and exit immediately. Optionally, write an integer weight after @ to adjust the probability of selecting this script versus other ones. The default weight is 1. See below for details.","names":["-b","--builtin"],"signature":"-b scriptname[@weight] --builtin = scriptname[@weight]"},{"description":"Number of clients simulated, that is, number of concurrent database sessions. Default is 1.","names":["-c","--client="],"signature":"-c clients --client= clients"},{"description":"Establish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead.","names":["-C","--connect"],"signature":"-C --connect"},{"description":"Define a variable for use by a custom script (see below). Multiple -D options are allowed.","names":["-D","--define="],"signature":"-D varname = value --define= varname = value"},{"description":"Add a transaction script read from filename to the list of scripts to be executed. Optionally, write an integer weight after @ to adjust the probability of selecting this script versus other ones. The default weight is 1. (To use a script file name that includes an @ character, append a weight so that there is no ambiguity, for example filen@me@1 .) See below for details.","names":["-f","--file="],"signature":"-f filename[@weight] --file= filename[@weight]"},{"description":"Number of worker threads within pgbench . Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1.","names":["-j","--jobs="],"signature":"-j threads --jobs= threads"},{"description":"Write information about each transaction to a log file. See below for details.","names":["-l","--log"],"signature":"-l --log"},{"description":"Transactions that last more than limit milliseconds are counted and reported separately, as late . When throttling is used ( --rate=... ), transactions that lag behind schedule by more than limit ms, and thus have no hope of meeting the latency limit, are not sent to the server at all. They are counted and reported separately as skipped . When the --max-tries option is used, a transaction which fails due to a serialization anomaly or from a deadlock will not be retried if the total time of all its tries is greater than limit ms. To limit only the time of tries and not their number, use --max-tries=0 . By default, the option --max-tries is set to 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions.","names":["-L","--latency-limit="],"signature":"-L limit --latency-limit= limit"},{"description":"Protocol to use for submitting queries to the server: simple : use simple query protocol. extended : use extended query protocol. prepared : use extended query protocol with prepared statements. In the prepared mode, pgbench reuses the parse analysis result starting from the second query iteration, so pgbench runs faster than in other modes. The default is simple query protocol. (See Chapter 54 for more information.)","names":["-M","--protocol="],"signature":"-M querymode --protocol= querymode"},{"description":"Perform no vacuuming before running the test. This option is necessary if you are running a custom test scenario that does not include the standard tables pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers .","names":["-n","--no-vacuum"],"signature":"-n --no-vacuum"},{"description":"Run built-in simple-update script. Shorthand for -b simple-update .","names":["-N","--skip-some-updates"],"signature":"-N --skip-some-updates"},{"description":"Show progress report every sec seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling ( -R ), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When --max-tries is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries.","names":["-P","--progress="],"signature":"-P sec --progress= sec"},{"description":"Report the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the --max-tries option is not equal to 1.","names":["-r","--report-per-command"],"signature":"-r --report-per-command"},{"description":"Execute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results. The rate is targeted by starting transactions along a Poisson-distributed schedule time line. The expected start time schedule moves forward based on when the client first started, not when the previous transaction ended. That approach means that when transactions go past their original scheduled end time, it is possible for later ones to catch up again. When throttling is active, the transaction latency reported at the end of the run is calculated from the scheduled start times, so it includes the time each transaction had to wait for the previous transaction to finish. The wait time is called the schedule lag time, and its average and maximum are also reported separately. The transaction latency with respect to the actual transaction start time, i.e., the time spent executing the transaction in the database, can be computed by subtracting the schedule lag time from the reported latency. If --latency-limit is used together with --rate , a transaction can lag behind so much that it is already over the latency limit when the previous transaction ends, because the latency is calculated from the scheduled start time. Such transactions are not sent to the server, but are skipped altogether and counted separately. A high schedule lag time is an indication that the system cannot process transactions at the specified rate, with the chosen number of clients and threads. When the average transaction execution time is longer than the scheduled interval between each transaction, each successive transaction will fall further behind, and the schedule lag time will keep increasing the longer the test run is. When that happens, you will have to reduce the specified transaction rate.","names":["-R","--rate="],"signature":"-R rate --rate= rate"},{"description":"Report the specified scale factor in pgbench '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 pgbench_branches table. However, when testing only custom benchmarks ( -f option), the scale factor will be reported as 1 unless this option is used.","names":["-s","--scale="],"signature":"-s scale_factor --scale= scale_factor"},{"description":"Run built-in select-only script. Shorthand for -b select-only .","names":["-S","--select-only"],"signature":"-S --select-only"},{"description":"Number of transactions each client runs. Default is 10.","names":["-t","--transactions="],"signature":"-t transactions --transactions= transactions"},{"description":"Run the test for this many seconds, rather than a fixed number of transactions per client. -t and -T are mutually exclusive.","names":["-T","--time="],"signature":"-T seconds --time= seconds"},{"description":"Vacuum all four standard tables before running the test. With neither -n nor -v , pgbench will vacuum the pgbench_tellers and pgbench_branches tables, and will truncate pgbench_history .","names":["-v","--vacuum-all"],"signature":"-v --vacuum-all"},{"description":"Length of aggregation interval (in seconds). May be used only with -l option. With this option, the log contains per-interval summary data, as described below.","names":["--aggregate-interval= seconds"],"signature":"--aggregate-interval= seconds"},{"description":"Exit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by -t or -T option, and pgbench will print an incomplete results in this case. Note that serialization failures or deadlock failures do not abort the client, so they are not affected by this option. See Failures and Serialization/Deadlock Retries for more information.","names":["--exit-on-abort"],"signature":"--exit-on-abort"},{"description":"Report failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types: serialization failures; deadlock failures; See Failures and Serialization/Deadlock Retries for more information.","names":["--failures-detailed"],"signature":"--failures-detailed"},{"description":"Set the filename prefix for the log files created by --log . The default is pgbench_log .","names":["--log-prefix= prefix"],"signature":"--log-prefix= prefix"},{"description":"Enable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the --latency-limit option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries ( --max-tries=0 ) without --latency-limit or --time . The default value is 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions.","names":["--max-tries= number_of_tries"],"signature":"--max-tries= number_of_tries"},{"description":"When showing progress (option -P ), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools.","names":["--progress-timestamp"],"signature":"--progress-timestamp"},{"description":"Set random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for seed may be: time (the default, the seed is based on the current time), rand (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script ( random... functions) or implicitly (for instance option --rate uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for seed may also be provided through the environment variable PGBENCH_RANDOM_SEED . To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable. Setting the seed explicitly allows to reproduce a pgbench run exactly, as far as random numbers are concerned. As the random state is managed per thread, this means the exact same pgbench run for an identical invocation if there is one client per thread and there are no external or data dependencies. From a statistical viewpoint reproducing runs exactly is a bad idea because it can hide the performance variability or improve performance unduly, e.g., by hitting the same pages as a previous run. However, it may also be of great help for debugging, for instance re-running a tricky case which leads to an error. Use wisely.","names":["--random-seed="],"signature":"--random-seed= seed"},{"description":"Sampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged. Remember to take the sampling rate into account when processing the log file. For example, when computing TPS values, you need to multiply the numbers accordingly (e.g., with 0.01 sample rate, you'll only get 1/100 of the actual TPS).","names":["--sampling-rate= rate"],"signature":"--sampling-rate= rate"},{"description":"Show the actual code of builtin script scriptname on stderr, and exit immediately.","names":["--show-script="],"signature":"--show-script= scriptname"},{"description":"Print messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See Failures and Serialization/Deadlock Retries for more information.","names":["--verbose-errors"],"signature":"--verbose-errors"},{"description":"Print debugging output.","names":["--debug"],"signature":"--debug"},{"description":"The database server's host name","names":["-h","--host="],"signature":"-h hostname --host= hostname"},{"description":"The database server's port number","names":["-p","--port="],"signature":"-p port --port= port"},{"description":"The user name to connect as","names":["-U","--username="],"signature":"-U login --username= login"},{"description":"Print the pgbench version and exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Show help about pgbench command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help"}],"synopsis":["pgbench -i [ option ...] [ dbname ]","pgbench [ option ...] [ dbname ]"]},"comparison_hash":"3fee128ed72e2dadb503883963e144eb39fe4ec647ea20726a6508671823ee62","description":["pgbench — run a benchmark test on PostgreSQL"],"description_zh":"描述 pgbench 是一个用于对 PostgreSQL 执行基准测试的简单程序。它会反复执行同一组 SQL 命令，也可在多个并发数据库会话中运行，然后计算平均事务速率（每秒事务数）。默认情况下， pgbench 测试的是一个大体上基于 TPC-B 的场景，每个事务包含五条 SELECT 、 UPDATE 和 INSERT 命令。不过，通过编写自己的事务脚本文件，也很容易测试其他场景。 典型的 pgbench 输出如下： transaction type: \u003cbuiltin: TPC-B (sort of)\u003e scaling factor: 10 query mode: simple number of clients: 10 number of threads: 1 maximum number of tries: 1 number of transactions per client: 1000 number of transactions actually processed: 10000/10000 number of failed transactions: 0 (0.000%) latency average = 11.013 ms latency stddev = 7.351 ms initial connection time = 45.758 ms tps = 896.967014 (without initial connection time) 前七行给出了若干最重要的参数设置。第六行报告了出现串行化或死锁错误时事务允许的最大尝试次数（更多信息见 失败和串行化/死锁重试 ）。第八行报告实际完成的事务数和预期事务数（后者仅为客户端数量与每个客户端事务数的乘积）；除非运行在完成前失败，或者某些 SQL 命令执行失败，否则两者应当相等。（在 -T 模式下，只打印实际事务数。）下一行报告因串行化或死锁错误而失败的事务数（更多信息见 失败和串行化/死锁重试 ）。最后一行报告每秒事务数。 默认的类 TPC-B 事务测试要求预先建立特定的表。应使用 -i （初始","description_zh_html":"\u003cp\u003e命令行工具 pgbench -i [ option ...] [ dbname ]\npgbench [ option ...] [ dbname ]。\u003c/p\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 是一个用于对 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 执行基准测试的简单程序。它会反复执行同一组 SQL 命令，也可在多个并发数据库会话中运行，然后计算平均事务速率（每秒事务数）。默认情况下，\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 测试的是一个大体上基于 TPC-B 的场景，每个事务包含五条 \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e、\u003ccode class=\"command\"\u003eUPDATE\u003c/code\u003e 和 \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e 命令。不过，通过编写自己的事务脚本文件，也很容易测试其他场景。\n \u003c/p\u003e\u003cp\u003e\n  典型的 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 输出如下：\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003etransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 10\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nlatency average = 11.013 ms\nlatency stddev = 7.351 ms\ninitial connection time = 45.758 ms\ntps = 896.967014 (without initial connection time)\n\u003c/pre\u003e\u003cp\u003e\n\n  前七行给出了若干最重要的参数设置。第六行报告了出现串行化或死锁错误时事务允许的最大尝试次数（更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e）。第八行报告实际完成的事务数和预期事务数（后者仅为客户端数量与每个客户端事务数的乘积）；除非运行在完成前失败，或者某些 SQL 命令执行失败，否则两者应当相等。（在 \u003ccode class=\"option\"\u003e-T\u003c/code\u003e 模式下，只打印实际事务数。）下一行报告因串行化或死锁错误而失败的事务数（更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e）。最后一行报告每秒事务数。\n\u003c/p\u003e\u003cp\u003e\n   默认的类 TPC-B 事务测试要求预先建立特定的表。应使用 \u003ccode class=\"option\"\u003e-i\u003c/code\u003e（初始化）选项调用 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 来创建并填充这些表。（测试自定义脚本时不需要这一步，但需要自行完成测试所需的准备工作。）初始化命令如下：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003epgbench -i [\u003cspan class=\"optional\"\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eother-options\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   其中 \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e 是已创建好的、用于执行测试的数据库名称。（可能还需要使用 \u003ccode class=\"option\"\u003e-h\u003c/code\u003e、\u003ccode class=\"option\"\u003e-p\u003c/code\u003e 和/或 \u003ccode class=\"option\"\u003e-U\u003c/code\u003e 选项来指定如何连接到数据库服务器。）\n  \u003c/p\u003e\u003cdiv class=\"caution\"\u003e\u003ch3 class=\"title\"\u003e小心\u003c/h3\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003epgbench -i\u003c/code\u003e 会创建四个表 \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e 和 \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e，并销毁任何已存在的同名表。如果数据库中已经存在这些名称的表，请务必改用其他数据库！\n   \u003c/p\u003e\u003c/div\u003e\u003cp\u003e\n   在默认的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e比例因子\u003c/span\u003e”\u003c/span\u003e 1 下，这些表最初包含如下行数：\n\u003c/p\u003e\u003cpre class=\"screen\"\u003etable                   # of rows\n---------------------------------\npgbench_branches        1\npgbench_tellers         10\npgbench_accounts        100000\npgbench_history         0\n\u003c/pre\u003e\u003cp\u003e\n   可以使用 \u003ccode class=\"option\"\u003e-s\u003c/code\u003e（比例因子）选项来增加行数，而且在大多数场景下通常也应该这样做。此时还可以配合使用 \u003ccode class=\"option\"\u003e-F\u003c/code\u003e（fillfactor）选项。\n  \u003c/p\u003e\u003cp\u003e\n   完成必要的准备后，就可以使用不带 \u003ccode class=\"option\"\u003e-i\u003c/code\u003e 的命令运行基准测试，也就是：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003epgbench [\u003cspan class=\"optional\"\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   几乎在所有情况下，都需要附加一些选项才能得到有意义的测试。最重要的选项是 \u003ccode class=\"option\"\u003e-c\u003c/code\u003e（客户端数）、\u003ccode class=\"option\"\u003e-t\u003c/code\u003e（事务数）、\u003ccode class=\"option\"\u003e-T\u003c/code\u003e（时间限制）以及 \u003ccode class=\"option\"\u003e-f\u003c/code\u003e（指定自定义脚本文件）。完整列表见下文。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\"\u003e\u003ch2\u003e选项\u003c/h2\u003e\u003cp\u003e\n   以下内容分为三个小节。数据库初始化和运行基准测试时使用不同的选项，但有些选项在这两种情况下都适用。\n  \u003c/p\u003e\u003cdiv class=\"refsect2\"\u003e\u003ch3\u003e初始化选项\u003c/h3\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 接受以下命令行初始化参数：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e[\u003cspan class=\"optional\"\u003e-d\u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e[\u003cspan class=\"optional\"\u003e--dbname=\u003c/span\u003e]\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定要测试的数据库名称。如果未指定，则使用环境变量 \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e。如果未设置该变量，则使用连接指定的用户名。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-i\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--initialize\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        进入初始化模式所必需。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-I \u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--init-steps=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅执行正常初始化步骤中的选定部分。\u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e 指定要执行的初始化步骤，每个步骤用一个字符表示。各步骤会按照指定顺序调用。默认值为 \u003ccode class=\"literal\"\u003edtgvp\u003c/code\u003e。可用步骤如下：\n\n        \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ed\u003c/code\u003e（删除）\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            删除任何现有的 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 表。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e（创建表）\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            创建标准 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 场景使用的表，即\n            \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e 和\n            \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eg\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003eG\u003c/code\u003e（在客户端或服务器端生成数据）\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            生成数据并将其装载到标准表中，替换其中任何已有数据。\n           \u003c/p\u003e\u003cp\u003e\n            使用 \u003ccode class=\"literal\"\u003eg\u003c/code\u003e（客户端生成数据）时，数据由 \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e 客户端生成，再通过 \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e 发送到服务器，因此会大量占用客户端/服务器带宽。对于 14 及以上版本的 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e，\u003ccode class=\"command\"\u003epgbench\u003c/code\u003e 会在普通（非分区）表上使用 \u003ccode class=\"option\"\u003eFREEZE\u003c/code\u003e 选项装载数据，以加快后续的 \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e。使用 \u003ccode class=\"literal\"\u003eg\u003c/code\u003e 时，在为所有表生成数据的过程中，每生成 100,000 行会输出一条日志消息。\n           \u003c/p\u003e\u003cp\u003e\n            使用 \u003ccode class=\"literal\"\u003eG\u003c/code\u003e（服务器端生成数据）时，\u003ccode class=\"command\"\u003epgbench\u003c/code\u003e 客户端只发送较小的查询，随后实际数据在服务器端生成。这种方式不需要大量带宽，但服务器会承担更多工作。使用 \u003ccode class=\"literal\"\u003eG\u003c/code\u003e 时，生成数据期间不会打印任何进度消息。\n           \u003c/p\u003e\u003cp\u003e\n            默认初始化行为使用客户端生成数据（等同于 \u003ccode class=\"literal\"\u003eg\u003c/code\u003e）。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ev\u003c/code\u003e（清理）\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            在标准表上调用 \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ep\u003c/code\u003e（创建主键）\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            在标准表上创建主键索引。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ef\u003c/code\u003e（创建外键）\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            在标准表之间创建外键约束。（请注意，默认情况下不执行此步骤。）\n           \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--fillfactor=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        以给定的 fillfactor 创建 \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e 和\n        \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e 表。默认值为 100。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        初始化期间不执行任何清理。（即使在 \u003ccode class=\"option\"\u003e-I\u003c/code\u003e 中指定了 \u003ccode class=\"literal\"\u003ev\u003c/code\u003e 步骤，此选项也会抑制它。）\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-q\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将日志切换为静默模式，每 5 秒只输出一条进度消息。默认日志每生成 100,000 行输出一条消息，因而往往会在每秒输出多行（尤其是在较好的硬件上）。\n       \u003c/p\u003e\u003cp\u003e\n        如果在 \u003ccode class=\"option\"\u003e-I\u003c/code\u003e 中指定了 \u003ccode class=\"literal\"\u003eG\u003c/code\u003e，则此设置无效。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--scale=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将生成的行数乘以比例因子。例如，\u003ccode class=\"literal\"\u003e-s 100\u003c/code\u003e 会在 \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e 表中创建 10,000,000 行。默认值为 1。当比例达到 20,000 或更大时，用于保存账户标识符的列（\u003ccode class=\"structfield\"\u003eaid\u003c/code\u003e 列）将切换到使用更大的整数（\u003ccode class=\"type\"\u003ebigint\u003c/code\u003e），以便容纳账户标识符的取值范围。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--foreign-keys\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在标准表之间创建外键约束。（如果初始化步骤序列中尚未包含 \u003ccode class=\"literal\"\u003ef\u003c/code\u003e 步骤，则此选项会把它加入进去。）\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--index-tablespace=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_tablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在指定的表空间中创建索引，而不是默认的表空间。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--partition-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        使用 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e 方法创建分区的 \u003ccode class=\"literal\"\u003epgbench_accounts\u003c/code\u003e 表。预期值为 \u003ccode class=\"literal\"\u003erange\u003c/code\u003e 或 \u003ccode class=\"literal\"\u003ehash\u003c/code\u003e。此选项要求 \u003ccode class=\"option\"\u003e--partitions\u003c/code\u003e 设置为非零值。若未指定，默认为 \u003ccode class=\"literal\"\u003erange\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--partitions=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        创建带有 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e 个大小近乎相等分区的 \u003ccode class=\"literal\"\u003epgbench_accounts\u003c/code\u003e 分区表，这些分区用于容纳按比例扩展后的账户数。默认值为 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e，表示不分区。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tablespace=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在指定的表空间中创建表，而不是默认的表空间。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--unlogged-tables\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将所有表创建为不记录 WAL 的表，而不是永久表。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect2\"\u003e\u003ch3\u003e基准测试选项\u003c/h3\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 接受以下命令行基准测试参数：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-b\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--builtin\u003c/code\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将指定的内置脚本添加到待执行脚本列表中。可用的内置脚本包括：\u003ccode class=\"literal\"\u003etpcb-like\u003c/code\u003e、\u003ccode class=\"literal\"\u003esimple-update\u003c/code\u003e 和 \u003ccode class=\"literal\"\u003eselect-only\u003c/code\u003e。也接受内置名称的无歧义前缀。使用特殊名称 \u003ccode class=\"literal\"\u003elist\u003c/code\u003e 时，会显示内置脚本列表并立即退出。\n       \u003c/p\u003e\u003cp\u003e\n        可选地，可在\u003ccode class=\"literal\"\u003e@\u003c/code\u003e后写一个整数权重，以调整此脚本相对于其他脚本的选中概率。默认权重为 1。详情请参见下文。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--client=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        模拟的客户端数量，也就是并发数据库会话的数量。默认值为 1。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--connect\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        为每个事务建立一个新连接，而不是仅在每个客户端会话中执行一次。这对于测量连接开销很有用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--define=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        定义一个变量，供自定义脚本使用（见下文）。允许使用多个 \u003ccode class=\"option\"\u003e-D\u003c/code\u003e 选项。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将从 \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e 读取的事务脚本添加到要执行的脚本列表中。\n       \u003c/p\u003e\u003cp\u003e\n        可选地，可在\u003ccode class=\"literal\"\u003e@\u003c/code\u003e后写一个整数权重，以调整此脚本相对于其他脚本的选中概率。默认权重为 1。（如果脚本文件名本身包含\u003ccode class=\"literal\"\u003e@\u003c/code\u003e字符，可追加一个权重以消除歧义，例如 \u003ccode class=\"literal\"\u003efilen@me@1\u003c/code\u003e。）详情见下文。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-j\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--jobs=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 中的工作线程数。在多 CPU 机器上使用多个线程可能会有所帮助。客户端尽可能均匀地分布在可用线程中。默认值为 1。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将每个事务的信息写入日志文件。详情见下文。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--latency-limit=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        持续时间超过 \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e 毫秒的事务会被单独计数和报告，称为 \u003cem class=\"firstterm\"\u003elate\u003c/em\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        使用限流（\u003ccode class=\"option\"\u003e--rate=...\u003c/code\u003e）时，若某个事务落后于计划时间超过 \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e 毫秒，从而已经不可能满足延迟限制，则它根本不会被发送到服务器。此类事务会被单独计数并报告为 \u003cem class=\"firstterm\"\u003eskipped\u003c/em\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        使用 \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e 选项时，若某个事务因串行化异常或死锁而失败，且其所有尝试的总耗时大于 \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e 毫秒，则不会再重试。若只想限制尝试总时间而不限制尝试次数，请使用 \u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e。默认情况下，\u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e 为 1，出现串行化/死锁错误的事务不会重试。有关此类事务重试的更多信息，见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-M\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--protocol=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        用于向服务器提交查询的协议：\n          \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003esimple\u003c/code\u003e：使用简单查询协议。\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003eextended\u003c/code\u003e：使用扩展查询协议。\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003eprepared\u003c/code\u003e：使用带有预备语句的扩展查询协议。\u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\n        在 \u003ccode class=\"literal\"\u003eprepared\u003c/code\u003e 模式下，\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e\n        从第二次查询迭代开始复用解析分析结果，因此 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e\n        比其他模式运行得更快。\n       \u003c/p\u003e\u003cp\u003e\n        默认值是简单查询协议。（更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/protocol.html\"\u003e第 54 章\u003c/a\u003e。）\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在运行测试前不执行任何清理。如果运行的是不包含标准表 \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e、\u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e 和\n        \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e 的自定义测试场景，则此选项是\u003cspan class=\"emphasis\"\u003e\u003cem\u003e必需的\u003c/em\u003e\u003c/span\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--skip-some-updates\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        运行内置的 simple-update 脚本。是 \u003ccode class=\"option\"\u003e-b simple-update\u003c/code\u003e 的简写。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        每 \u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e 秒显示一次进度报告。报告包括自运行开始以来的时间、自上次报告以来的 TPS、自上次报告以来事务延迟的平均值和标准差，以及失败事务数。使用限流（\u003ccode class=\"option\"\u003e-R\u003c/code\u003e）时，延迟是相对于事务计划开始时间计算的，而不是实际开始时间，因此其中也包含平均计划滞后时间。当使用 \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e 启用事务在串行化/死锁错误后的重试时，报告还会包含发生过重试的事务数以及总重试次数。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-r\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--report-per-command\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在基准测试完成后，报告每条命令的以下统计信息：平均延迟（从客户端视角看到的语句执行时间）、失败次数，以及该命令因串行化或死锁错误而发生的重试次数。仅当 \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e 选项不等于 1 时，报告才会显示重试统计信息。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--rate=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        以指定速率执行事务，而不是像默认行为那样尽可能快地运行。速率以每秒事务数表示。如果目标速率高于可达到的最大速率，则速率限制不会影响结果。\n       \u003c/p\u003e\u003cp\u003e\n        该速率通过让事务沿着一条符合泊松分布的时间线启动来实现。预期开始时间表是根据客户端首次启动的时间向前推进的，而不是根据前一个事务结束的时间。这意味着，当某些事务超过其原定结束时间时，后续事务仍有可能重新赶上计划。\n       \u003c/p\u003e\u003cp\u003e\n        启用限流后，运行结束时报告的事务延迟是从计划开始时间计算的，因此它包含每个事务等待前一个事务完成的时间。这段等待时间称为计划滞后时间，其平均值和最大值也会单独报告。若要得到相对于事务实际开始时间的延迟，也就是事务在数据库中实际执行所花费的时间，可以用报告中的延迟减去计划滞后时间。\n       \u003c/p\u003e\u003cp\u003e\n        如果同时使用 \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e 和 \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e，一个事务可能会落后太多，以至于在前一个事务结束时已经超过了延迟限制，因为延迟是从计划开始时间计算的。这样的事务不会发送到服务器，而是完全跳过并单独计数。\n       \u003c/p\u003e\u003cp\u003e\n        较高的计划滞后时间表明，在所选客户端数和线程数下，系统无法以指定速率处理事务。当平均事务执行时间长于事务之间的计划间隔时，后续事务会不断进一步落后，而计划滞后时间也会随着测试持续时间增加。在这种情况下，需要降低指定的事务速率。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--scale=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 输出中报告指定的比例因子。对于内置测试，这没有必要；系统会通过统计 \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e 表中的行数来检测正确的比例因子。但在只测试自定义基准（\u003ccode class=\"option\"\u003e-f\u003c/code\u003e 选项）时，除非使用此选项，否则比例因子会被报告为 1。\n\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--select-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        运行内置的 select-only 脚本。是 \u003ccode class=\"option\"\u003e-b select-only\u003c/code\u003e 的简写。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--transactions=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        每个客户端运行的事务数量。默认值为 10。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--time=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        让测试运行指定的秒数，而不是让每个客户端执行固定数量的事务。\u003ccode class=\"option\"\u003e-t\u003c/code\u003e 和\n        \u003ccode class=\"option\"\u003e-T\u003c/code\u003e 是互斥的。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--vacuum-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在运行测试之前，对四个标准表全部执行清理。如果既不使用 \u003ccode class=\"option\"\u003e-n\u003c/code\u003e 也不使用 \u003ccode class=\"option\"\u003e-v\u003c/code\u003e，\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 会对\n        \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e 和 \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e\n        表进行清理，并截断 \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--aggregate-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        聚合间隔的长度（以秒为单位）。只能与 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e 选项一起使用。使用此选项时，日志包含每个间隔的摘要数据，如下所述。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        当任一客户端因错误被中止时，立即退出。如果不指定该选项，即使某个客户端被中止，其他客户端仍可按 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 或 \u003ccode class=\"option\"\u003e-T\u003c/code\u003e 的设定继续运行，此时 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 会输出不完整的结果。\n       \u003c/p\u003e\u003cp\u003e\n        请注意，串行化失败或死锁失败不会中止客户端，因此不受该选项影响。更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在逐事务日志、聚合日志以及主报告和逐脚本报告中，按以下类型分组报告失败：\n        \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e串行化失败；\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e死锁失败；\u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n        更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log-prefix=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设置由 \u003ccode class=\"option\"\u003e--log\u003c/code\u003e 创建的日志文件的文件名前缀。默认值为 \u003ccode class=\"literal\"\u003epgbench_log\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--max-tries=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_of_tries\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        启用对出现串行化/死锁错误的事务进行重试，并设置最大尝试次数。此选项可与\n        \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e 组合使用，后者限制同一事务所有尝试的总耗时；此外，如果没有 \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e 或 \u003ccode class=\"option\"\u003e--time\u003c/code\u003e，则不能使用无限次尝试（\u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e）。默认值为 1，出现串行化/死锁错误的事务不会重试。有关此类事务重试的更多信息，见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress-timestamp\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        显示进度（选项 \u003ccode class=\"option\"\u003e-P\u003c/code\u003e）时，使用时间戳（Unix 纪元）而不是自运行开始以来的秒数。单位为秒，小数点后精确到毫秒。这有助于比较各种工具生成的日志。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--random-seed=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        设置随机数生成器种子。它会先为系统随机数生成器设种，再生成一系列初始生成器状态，每个线程一个。\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e 的取值可以是：\u003ccode class=\"literal\"\u003etime\u003c/code\u003e（默认值，种子基于当前时间），\u003ccode class=\"literal\"\u003erand\u003c/code\u003e（使用强随机源，如果没有可用的则失败），或者无符号十进制整数值。随机生成器既可以在 pgbench 脚本中显式调用（\u003ccode class=\"literal\"\u003erandom...\u003c/code\u003e函数），也可以隐式调用（例如选项\n        \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e 用于调度事务）。显式设置时，实际用于设种的值会显示在终端上。任何允许的 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e 值也可以通过环境变量\n        \u003ccode class=\"literal\"\u003ePGBENCH_RANDOM_SEED\u003c/code\u003e 提供。为确保提供的种子影响所有可能的用途，将此选项放在第一位或使用环境变量。\n      \u003c/p\u003e\u003cp\u003e\n        显式设置种子可以在随机数层面精确复现一次 \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e 运行。由于随机状态按线程管理，这意味着对于相同的调用，如果每个线程只有一个客户端，且不存在外部依赖或数据依赖，那么 \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e 运行可以完全一致。从统计角度看，精确复现实验并不是好主意，因为它可能掩盖性能波动，甚至不恰当地提高性能，例如反复命中与前一次运行相同的页面。不过，这对调试也可能非常有帮助，例如重现会触发错误的棘手案例。请谨慎使用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sampling-rate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        写入日志时使用的采样率，用于减少生成的日志量。如果给定此选项，则只记录指定比例的事务。1.0 表示记录全部事务，0.05 表示只记录 5% 的事务。\n       \u003c/p\u003e\u003cp\u003e\n        处理日志文件时，记得把采样率考虑进去。例如，计算 TPS 值时，需要按采样率对数字进行相应换算（例如采样率为 0.01 时，只能得到实际 TPS 的 1/100）。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--show-script=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将内置脚本 \u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e 的实际代码输出到 stderr，然后立即退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        打印关于所有错误和失败（不再重试的错误）的消息，包括超出了哪一种重试限制，以及对于串行化/死锁失败超出的幅度。（请注意，这种情况下输出量可能会显著增加。）更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/pgbench.html#FAILURES-AND-RETRIES\"\u003e失败和串行化/死锁重试\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect2\"\u003e\u003ch3\u003e公共选项\u003c/h3\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 还接受以下用于连接参数及其他通用设置的命令行参数：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        打印调试输出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        数据库服务器的主机名。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        数据库服务器的端口号。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        连接时使用的用户名。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        打印 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 版本并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        显示 \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e 命令行参数的帮助信息并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/pgbench.html\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","environment":[{"description":"Default connection parameters.","name":"PGDATABASE PGHOST PGPORT PGUSER"}],"facts":[{"label":"Documented executable","value":"pgbench"},{"label":"Executable version","value":"18.6"},{"label":"Reference inventory","value":"Client applications"},{"label":"Option definition groups","value":"47"}],"facts_zh":[{"label":"手册中的可执行程序","value":"“ 事务 ”"},{"label":"程序版本","value":"18.6"},{"label":"参考清单","value":"客户端程序"},{"label":"选项定义组","value":"47"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"PGBENCH\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epgbench — run a benchmark test on \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.11.4.1\"\u003e\u003ccode class=\"command\"\u003epgbench\u003c/code\u003e \u003ccode class=\"option\"\u003e-i\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.11.4.2\"\u003e\u003ccode class=\"command\"\u003epgbench\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e is a simple program for running benchmark tests on \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. 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, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e tests a scenario that is loosely based on TPC-B, involving five \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e, \u003ccode class=\"command\"\u003eUPDATE\u003c/code\u003e, and \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e commands per transaction. However, it is easy to test other cases by writing your own transaction script files.\u003c/p\u003e\n\u003cp\u003eTypical output from \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e looks like:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003etransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 10\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nlatency average = 11.013 ms\nlatency stddev = 7.351 ms\ninitial connection time = 45.758 ms\ntps = 896.967014 (without initial connection time)\n\u003c/pre\u003e\n\u003cp\u003eThe first seven lines report some of the most important parameter settings. The sixth line reports the maximum number of tries for transactions with serialization or deadlock errors (see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information). The eighth line reports the number of transactions completed and intended (the latter being just the product of number of clients and number of transactions per client); these will be equal unless the run failed before completion or some SQL command(s) failed. (In \u003ccode class=\"option\"\u003e-T\u003c/code\u003e mode, only the actual number of transactions is printed.) The next line reports the number of failed transactions due to serialization or deadlock errors (see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information). The last line reports the number of transactions per second.\u003c/p\u003e\n\u003cp\u003eThe default TPC-B-like transaction test requires specific tables to be set up beforehand. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e should be invoked with the \u003ccode class=\"option\"\u003e-i\u003c/code\u003e (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:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epgbench -i [\u003cspan class=\"optional\"\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eother-options\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003ewhere \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e is the name of the already-created database to test in. (You may also need \u003ccode class=\"option\"\u003e-h\u003c/code\u003e, \u003ccode class=\"option\"\u003e-p\u003c/code\u003e, and/or \u003ccode class=\"option\"\u003e-U\u003c/code\u003e options to specify how to connect to the database server.)\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epgbench -i\u003c/code\u003e creates four tables \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e, and \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e, destroying any existing tables of these names. Be very careful to use another database if you have tables having these names!\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eAt the default \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003escale factor\u003c/span\u003e”\u003c/span\u003e of 1, the tables initially contain this many rows:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003etable                   # of rows\n---------------------------------\npgbench_branches        1\npgbench_tellers         10\npgbench_accounts        100000\npgbench_history         0\n\u003c/pre\u003e\n\u003cp\u003eYou can (and, for most purposes, probably should) increase the number of rows by using the \u003ccode class=\"option\"\u003e-s\u003c/code\u003e (scale factor) option. The \u003ccode class=\"option\"\u003e-F\u003c/code\u003e (fillfactor) option might also be used at this point.\u003c/p\u003e\n\u003cp\u003eOnce you have done the necessary setup, you can run your benchmark with a command that doesn't include \u003ccode class=\"option\"\u003e-i\u003c/code\u003e, that is\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epgbench [\u003cspan class=\"optional\"\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003eIn nearly all cases, you'll need some options to make a useful test. The most important options are \u003ccode class=\"option\"\u003e-c\u003c/code\u003e (number of clients), \u003ccode class=\"option\"\u003e-t\u003c/code\u003e (number of transactions), \u003ccode class=\"option\"\u003e-T\u003c/code\u003e (time limit), and \u003ccode class=\"option\"\u003e-f\u003c/code\u003e (specify a custom script file). See below for a full list.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003eThe following is divided into three subsections. Different options are used during database initialization and while running benchmarks, but some options are useful in both cases.\u003c/p\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-INIT-OPTIONS\"\u003e\n\u003ch3\u003eInitialization Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e accepts the following command-line initialization arguments:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-DBNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e[\u003cspan class=\"optional\"\u003e-d\u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e[\u003cspan class=\"optional\"\u003e--dbname=\u003c/span\u003e]\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the name of the database to test in. If this is not specified, the environment variable \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e is used. If that is not set, the user name specified for the connection is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INITIALIZE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-i\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--initialize\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequired to invoke initialization mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-I \u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--init-steps=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform just a selected set of the normal initialization steps. \u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is \u003ccode class=\"literal\"\u003edtgvp\u003c/code\u003e. The available steps are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-D\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ed\u003c/code\u003e (Drop)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDrop any existing \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-T\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e (create Tables)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate the tables used by the standard \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e scenario, namely \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e, and \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-G\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eg\u003c/code\u003e or \u003ccode class=\"literal\"\u003eG\u003c/code\u003e (Generate data, client-side or server-side)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGenerate data and load it into the standard tables, replacing any data already present.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode class=\"literal\"\u003eg\u003c/code\u003e (client-side data generation), data is generated in \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e client and then sent to the server. This uses the client/server bandwidth extensively through a \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e. \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e uses the \u003ccode class=\"option\"\u003eFREEZE\u003c/code\u003e option to load data into ordinary (non-partition) tables with version 14 or later of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e to speed up subsequent \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e. Using \u003ccode class=\"literal\"\u003eg\u003c/code\u003e causes logging to print one message every 100,000 rows while generating data for all tables.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode class=\"literal\"\u003eG\u003c/code\u003e (server-side data generation), only small queries are sent from the \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e client and then data is actually generated in the server. No significant bandwidth is required for this variant, but the server will do more work. Using \u003ccode class=\"literal\"\u003eG\u003c/code\u003e causes logging not to print any progress message while generating data.\u003c/p\u003e\n\u003cp\u003eThe default initialization behavior uses client-side data generation (equivalent to \u003ccode class=\"literal\"\u003eg\u003c/code\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-V\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ev\u003c/code\u003e (Vacuum)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eInvoke \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e on the standard tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-P\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ep\u003c/code\u003e (create Primary keys)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate primary key indexes on the standard tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-F\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ef\u003c/code\u003e (create Foreign keys)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate foreign key constraints between the standard tables. (Note that this step is not performed by default.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FILLFACTOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--fillfactor=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate the \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e and \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e tables with the given fillfactor. Default is 100.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-NO-VACUUM-INIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform no vacuuming during initialization. (This option suppresses the \u003ccode class=\"literal\"\u003ev\u003c/code\u003e initialization step, even if it was specified in \u003ccode class=\"option\"\u003e-I\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-QUIET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-q\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware).\u003c/p\u003e\n\u003cp\u003eThis setting has no effect if \u003ccode class=\"literal\"\u003eG\u003c/code\u003e is specified in \u003ccode class=\"option\"\u003e-I\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SCALE-INIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--scale=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMultiply the number of rows generated by the scale factor. For example, \u003ccode class=\"literal\"\u003e-s 100\u003c/code\u003e will create 10,000,000 rows in the \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers (\u003ccode class=\"structfield\"\u003eaid\u003c/code\u003e columns) will switch to using larger integers (\u003ccode class=\"type\"\u003ebigint\u003c/code\u003e), in order to be big enough to hold the range of account identifiers.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FOREIGN-KEYS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--foreign-keys\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate foreign key constraints between the standard tables. (This option adds the \u003ccode class=\"literal\"\u003ef\u003c/code\u003e step to the initialization step sequence, if it is not already present.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INDEX-TABLESPACE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--index-tablespace=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_tablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate indexes in the specified tablespace, rather than the default tablespace.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PARTITION-METHOD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--partition-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a partitioned \u003ccode class=\"literal\"\u003epgbench_accounts\u003c/code\u003e table with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e method. Expected values are \u003ccode class=\"literal\"\u003erange\u003c/code\u003e or \u003ccode class=\"literal\"\u003ehash\u003c/code\u003e. This option requires that \u003ccode class=\"option\"\u003e--partitions\u003c/code\u003e is set to non-zero. If unspecified, default is \u003ccode class=\"literal\"\u003erange\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PARTITIONS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--partitions=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a partitioned \u003ccode class=\"literal\"\u003epgbench_accounts\u003c/code\u003e table with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e partitions of nearly equal size for the scaled number of accounts. Default is \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, meaning no partitioning.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TABLESPACE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tablespace=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate tables in the specified tablespace, rather than the default tablespace.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-UNLOGGED-TABLES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--unlogged-tables\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate all tables as unlogged tables, rather than permanent tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-RUN-OPTIONS\"\u003e\n\u003ch3\u003eBenchmarking Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e accepts the following command-line benchmarking arguments:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-BUILTIN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-b\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--builtin\u003c/code\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAdd the specified built-in script to the list of scripts to be executed. Available built-in scripts are: \u003ccode class=\"literal\"\u003etpcb-like\u003c/code\u003e, \u003ccode class=\"literal\"\u003esimple-update\u003c/code\u003e and \u003ccode class=\"literal\"\u003eselect-only\u003c/code\u003e. Unambiguous prefixes of built-in names are accepted. With the special name \u003ccode class=\"literal\"\u003elist\u003c/code\u003e, show the list of built-in scripts and exit immediately.\u003c/p\u003e\n\u003cp\u003eOptionally, write an integer weight after \u003ccode class=\"literal\"\u003e@\u003c/code\u003e to adjust the probability of selecting this script versus other ones. The default weight is 1. See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-CLIENT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--client=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of clients simulated, that is, number of concurrent database sessions. Default is 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-CONNECT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--connect\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEstablish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-DEFINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--define=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefine a variable for use by a custom script (see below). Multiple \u003ccode class=\"option\"\u003e-D\u003c/code\u003e options are allowed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAdd a transaction script read from \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e to the list of scripts to be executed.\u003c/p\u003e\n\u003cp\u003eOptionally, write an integer weight after \u003ccode class=\"literal\"\u003e@\u003c/code\u003e to adjust the probability of selecting this script versus other ones. The default weight is 1. (To use a script file name that includes an \u003ccode class=\"literal\"\u003e@\u003c/code\u003e character, append a weight so that there is no ambiguity, for example \u003ccode class=\"literal\"\u003efilen@me@1\u003c/code\u003e.) See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-JOBS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-j\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--jobs=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of worker threads within \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e. Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LOG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite information about each transaction to a log file. See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LATENCY-LIMIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--latency-limit=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTransactions that last more than \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e milliseconds are counted and reported separately, as \u003cem class=\"firstterm\"\u003elate\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eWhen throttling is used (\u003ccode class=\"option\"\u003e--rate=...\u003c/code\u003e), transactions that lag behind schedule by more than \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e ms, and thus have no hope of meeting the latency limit, are not sent to the server at all. They are counted and reported separately as \u003cem class=\"firstterm\"\u003eskipped\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is used, a transaction which fails due to a serialization anomaly or from a deadlock will not be retried if the total time of all its tries is greater than \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e ms. To limit only the time of tries and not their number, use \u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e. By default, the option \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is set to 1 and transactions with serialization/deadlock errors are not retried. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information about retrying such transactions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROTOCOL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-M\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--protocol=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eProtocol to use for submitting queries to the server:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003esimple\u003c/code\u003e: use simple query protocol.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eextended\u003c/code\u003e: use extended query protocol.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eprepared\u003c/code\u003e: use extended query protocol with prepared statements.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eIn the \u003ccode class=\"literal\"\u003eprepared\u003c/code\u003e mode, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e reuses the parse analysis result starting from the second query iteration, so \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e runs faster than in other modes.\u003c/p\u003e\n\u003cp\u003eThe default is simple query protocol. (See \u003ca class=\"xref\" href=\"/docs/18/protocol.html\" title=\"Chapter 54. Frontend/Backend Protocol\"\u003eChapter 54\u003c/a\u003e for more information.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-NO-VACUUM-RUN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform no vacuuming before running the test. This option is \u003cspan class=\"emphasis\"\u003e\u003cem\u003enecessary\u003c/em\u003e\u003c/span\u003e if you are running a custom test scenario that does not include the standard tables \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e, and \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SKIP-SOME-UPDATES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--skip-some-updates\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun built-in simple-update script. Shorthand for \u003ccode class=\"option\"\u003e-b simple-update\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROGRESS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow progress report every \u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling (\u003ccode class=\"option\"\u003e-R\u003c/code\u003e), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-REPORT-LATENCIES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-r\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--report-per-command\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-RATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--rate=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExecute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results.\u003c/p\u003e\n\u003cp\u003eThe rate is targeted by starting transactions along a Poisson-distributed schedule time line. The expected start time schedule moves forward based on when the client first started, not when the previous transaction ended. That approach means that when transactions go past their original scheduled end time, it is possible for later ones to catch up again.\u003c/p\u003e\n\u003cp\u003eWhen throttling is active, the transaction latency reported at the end of the run is calculated from the scheduled start times, so it includes the time each transaction had to wait for the previous transaction to finish. The wait time is called the schedule lag time, and its average and maximum are also reported separately. The transaction latency with respect to the actual transaction start time, i.e., the time spent executing the transaction in the database, can be computed by subtracting the schedule lag time from the reported latency.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e is used together with \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e, a transaction can lag behind so much that it is already over the latency limit when the previous transaction ends, because the latency is calculated from the scheduled start time. Such transactions are not sent to the server, but are skipped altogether and counted separately.\u003c/p\u003e\n\u003cp\u003eA high schedule lag time is an indication that the system cannot process transactions at the specified rate, with the chosen number of clients and threads. When the average transaction execution time is longer than the scheduled interval between each transaction, each successive transaction will fall further behind, and the schedule lag time will keep increasing the longer the test run is. When that happens, you will have to reduce the specified transaction rate.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SCALE-RUN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--scale=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport the specified scale factor in \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e'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 \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e table. However, when testing only custom benchmarks (\u003ccode class=\"option\"\u003e-f\u003c/code\u003e option), the scale factor will be reported as 1 unless this option is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SELECT-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--select-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun built-in select-only script. Shorthand for \u003ccode class=\"option\"\u003e-b select-only\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TRANSACTIONS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--transactions=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of transactions each client runs. Default is 10.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TIME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--time=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun the test for this many seconds, rather than a fixed number of transactions per client. \u003ccode class=\"option\"\u003e-t\u003c/code\u003e and \u003ccode class=\"option\"\u003e-T\u003c/code\u003e are mutually exclusive.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VACUUM-ALL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--vacuum-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eVacuum all four standard tables before running the test. With neither \u003ccode class=\"option\"\u003e-n\u003c/code\u003e nor \u003ccode class=\"option\"\u003e-v\u003c/code\u003e, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e will vacuum the \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e and \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e tables, and will truncate \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-AGGREGATE-INTERVAL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--aggregate-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLength of aggregation interval (in seconds). May be used only with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e option. With this option, the log contains per-interval summary data, as described below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-EXIT-ON-ABORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by \u003ccode class=\"option\"\u003e-t\u003c/code\u003e or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e option, and \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e will print an incomplete results in this case.\u003c/p\u003e\n\u003cp\u003eNote that serialization failures or deadlock failures do not abort the client, so they are not affected by this option. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FAILURES-DETAILED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eserialization failures;\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003edeadlock failures;\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eSee \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LOG-PREFIX\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log-prefix=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the filename prefix for the log files created by \u003ccode class=\"option\"\u003e--log\u003c/code\u003e. The default is \u003ccode class=\"literal\"\u003epgbench_log\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-MAX-TRIES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--max-tries=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_of_tries\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries (\u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e) without \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e or \u003ccode class=\"option\"\u003e--time\u003c/code\u003e. The default value is 1 and transactions with serialization/deadlock errors are not retried. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information about retrying such transactions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROGRESS-TIMESTAMP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress-timestamp\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen showing progress (option \u003ccode class=\"option\"\u003e-P\u003c/code\u003e), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-RANDOM-SEED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--random-seed=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e may be: \u003ccode class=\"literal\"\u003etime\u003c/code\u003e (the default, the seed is based on the current time), \u003ccode class=\"literal\"\u003erand\u003c/code\u003e (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script (\u003ccode class=\"literal\"\u003erandom...\u003c/code\u003e functions) or implicitly (for instance option \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e may also be provided through the environment variable \u003ccode class=\"literal\"\u003ePGBENCH_RANDOM_SEED\u003c/code\u003e. To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable.\u003c/p\u003e\n\u003cp\u003eSetting the seed explicitly allows to reproduce a \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e run exactly, as far as random numbers are concerned. As the random state is managed per thread, this means the exact same \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e run for an identical invocation if there is one client per thread and there are no external or data dependencies. From a statistical viewpoint reproducing runs exactly is a bad idea because it can hide the performance variability or improve performance unduly, e.g., by hitting the same pages as a previous run. However, it may also be of great help for debugging, for instance re-running a tricky case which leads to an error. Use wisely.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SAMPLING-RATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sampling-rate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged.\u003c/p\u003e\n\u003cp\u003eRemember to take the sampling rate into account when processing the log file. For example, when computing TPS values, you need to multiply the numbers accordingly (e.g., with 0.01 sample rate, you'll only get 1/100 of the actual TPS).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SHOW-SCRIPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--show-script=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow the actual code of builtin script \u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e on stderr, and exit immediately.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VERBOSE-ERRORS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-COMMON-OPTIONS\"\u003e\n\u003ch3\u003eCommon Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e also accepts the following common command-line arguments for connection parameters and other common settings:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-DEBUG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint debugging output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server's host name\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server's port number\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-USERNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe user name to connect as\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003eA successful run will exit with status 0. Exit status 1 indicates static problems such as invalid command-line options or internal errors which are supposed to never occur. Early errors that occur when starting benchmark such as initial connection failures also exit with status 1. Errors during the run such as database errors or problems in the script will result in exit status 2. In the latter case, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e will print partial results if \u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e option is not specified.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.8\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-ENVIRONMENT-PGDATABASE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.9\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cdiv class=\"refsect2\" id=\"TRANSACTIONS-AND-SCRIPTS\"\u003e\n\u003ch3\u003eWhat Is the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eTransaction\u003c/span\u003e”\u003c/span\u003e Actually Performed in \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e?\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e executes test scripts chosen randomly from a specified list. The scripts may include built-in scripts specified with \u003ccode class=\"option\"\u003e-b\u003c/code\u003e and user-provided scripts specified with \u003ccode class=\"option\"\u003e-f\u003c/code\u003e. Each script may be given a relative weight specified after an \u003ccode class=\"literal\"\u003e@\u003c/code\u003e so as to change its selection probability. The default weight is \u003ccode class=\"literal\"\u003e1\u003c/code\u003e. Scripts with a weight of \u003ccode class=\"literal\"\u003e0\u003c/code\u003e are ignored.\u003c/p\u003e\n\u003cp\u003eThe default built-in transaction script (also invoked with \u003ccode class=\"option\"\u003e-b tpcb-like\u003c/code\u003e) issues seven commands per transaction over randomly chosen \u003ccode class=\"literal\"\u003eaid\u003c/code\u003e, \u003ccode class=\"literal\"\u003etid\u003c/code\u003e, \u003ccode class=\"literal\"\u003ebid\u003c/code\u003e and \u003ccode class=\"literal\"\u003edelta\u003c/code\u003e. The scenario is inspired by the TPC-B benchmark, but is not actually TPC-B, hence the name.\u003c/p\u003e\n\u003cdiv class=\"orderedlist\"\u003e\n\u003col class=\"orderedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eBEGIN;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eUPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eSELECT abalance FROM pgbench_accounts WHERE aid = :aid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eUPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eUPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eINSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eEND;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n\u003cp\u003eIf you select the \u003ccode class=\"literal\"\u003esimple-update\u003c/code\u003e built-in (also \u003ccode class=\"option\"\u003e-N\u003c/code\u003e), steps 4 and 5 aren't included in the transaction. This will avoid update contention on these tables, but it makes the test case even less like TPC-B.\u003c/p\u003e\n\u003cp\u003eIf you select the \u003ccode class=\"literal\"\u003eselect-only\u003c/code\u003e built-in (also \u003ccode class=\"option\"\u003e-S\u003c/code\u003e), only the \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e is issued.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.3\"\u003e\n\u003ch3\u003eCustom Scripts\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e has support for running custom benchmark scenarios by replacing the default transaction script (described above) with a transaction script read from a file (\u003ccode class=\"option\"\u003e-f\u003c/code\u003e option). In this case a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etransaction\u003c/span\u003e”\u003c/span\u003e counts as one execution of a script file.\u003c/p\u003e\n\u003cp\u003eA script file contains one or more SQL commands terminated by semicolons. Empty lines and lines beginning with \u003ccode class=\"literal\"\u003e--\u003c/code\u003e are ignored. Script files can also contain \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003emeta commands\u003c/span\u003e”\u003c/span\u003e, which are interpreted by \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e itself, as described below.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eBefore \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, SQL commands in script files were terminated by newlines, and so they could not be continued across lines. Now a semicolon is \u003cspan class=\"emphasis\"\u003e\u003cem\u003erequired\u003c/em\u003e\u003c/span\u003e to separate consecutive SQL commands (though an SQL command does not need one if it is followed by a meta command). If you need to create a script file that works with both old and new versions of \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e, be sure to write each SQL command on a single line ending with a semicolon.\u003c/p\u003e\n\u003cp\u003eIt is assumed that \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e scripts do not contain incomplete blocks of SQL transactions. If at runtime the client reaches the end of the script without completing the last transaction block, it will be aborted.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThere is a simple variable-substitution facility for script files. Variable names must consist of letters (including non-Latin letters), digits, and underscores, with the first character not being a digit. Variables can be set by the command-line \u003ccode class=\"option\"\u003e-D\u003c/code\u003e option, explained above, or by the meta commands explained below. In addition to any variables preset by \u003ccode class=\"option\"\u003e-D\u003c/code\u003e command-line options, there are a few variables that are preset automatically, listed in \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#PGBENCH-AUTOMATIC-VARIABLES\" title=\"Table 301. pgbench Automatic Variables\"\u003eTable 301\u003c/a\u003e. A value specified for these variables using \u003ccode class=\"option\"\u003e-D\u003c/code\u003e takes precedence over the automatic presets. Once set, a variable's value can be inserted into an SQL command by writing \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e. When running more than one client session, each session has its own set of variables. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e supports up to 255 variable uses in one statement.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"PGBENCH-AUTOMATIC-VARIABLES\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 301. pgbench Automatic Variables\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eVariable\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003eclient_id\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eunique number identifying the client session (starts from zero)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003edefault_seed\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eseed used in hash and pseudorandom permutation functions by default\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003erandom_seed\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003erandom generator seed (unless overwritten with \u003ccode class=\"option\"\u003e-D\u003c/code\u003e)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003escale\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003ecurrent scale factor\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eScript file meta commands begin with a backslash (\u003ccode class=\"literal\"\u003e\\\u003c/code\u003e) and normally extend to the end of the line, although they can be continued to additional lines by writing backslash-return. Arguments to a meta command are separated by white space. These meta commands are supported:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-GSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gset [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e \u003ccode class=\"literal\"\u003e\\aset [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese commands may be used to end SQL queries, taking the place of the terminating semicolon (\u003ccode class=\"literal\"\u003e;\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"literal\"\u003e\\gset\u003c/code\u003e command is used, the preceding SQL query is expected to return one row, the columns of which are stored into variables named after column names, and prefixed with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e if provided.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"literal\"\u003e\\aset\u003c/code\u003e command is used, all combined SQL queries (separated by \u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e) have their columns stored into variables named after column names, and prefixed with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e if provided. If a query returns no row, no assignment is made and the variable can be tested for existence to detect this. If a query returns more than one row, the last value is kept.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\gset\u003c/code\u003e and \u003ccode class=\"literal\"\u003e\\aset\u003c/code\u003e cannot be used in pipeline mode, since the query results are not yet available by the time the commands would need them.\u003c/p\u003e\n\u003cp\u003eThe following example puts the final account balance from the first query into variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003eabalance\u003c/code\u003e\u003c/em\u003e, and fills variables \u003cem class=\"replaceable\"\u003e\u003ccode\u003ep_two\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ep_three\u003c/code\u003e\u003c/em\u003e with integers from the third query. The result of the second query is discarded. The result of the two last combined queries are stored in variables \u003cem class=\"replaceable\"\u003e\u003ccode\u003efour\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003efive\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eUPDATE pgbench_accounts\n  SET abalance = abalance + :delta\n  WHERE aid = :aid\n  RETURNING abalance \\gset\n-- compound of two queries\nSELECT 1 \\;\nSELECT 2 AS two, 3 AS three \\gset p_\nSELECT 4 AS four \\; SELECT 5 AS five \\aset\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-IF-ELSE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\if\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\elif\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\else\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endif\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements nestable conditional blocks, similarly to \u003ccode class=\"literal\"\u003epsql\u003c/code\u003e's \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#PSQL-METACOMMAND-IF\"\u003e\u003ccode class=\"literal\"\u003e\\if\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e. Conditional expressions are identical to those with \u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e, with non-zero values interpreted as true.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\set \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e to a value calculated from \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e. The expression may contain the \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e constant, Boolean constants \u003ccode class=\"literal\"\u003eTRUE\u003c/code\u003e and \u003ccode class=\"literal\"\u003eFALSE\u003c/code\u003e, integer constants such as \u003ccode class=\"literal\"\u003e5432\u003c/code\u003e, double constants such as \u003ccode class=\"literal\"\u003e3.14159\u003c/code\u003e, references to variables \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e, \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-BUILTIN-OPERATORS\" title=\"Built-in Operators\"\u003eoperators\u003c/a\u003e with their usual SQL precedence and associativity, \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-BUILTIN-FUNCTIONS\" title=\"Built-In Functions\"\u003efunction calls\u003c/a\u003e, SQL \u003ca class=\"link\" href=\"/docs/18/functions-conditional.html#FUNCTIONS-CASE\" title=\"9.18.1. CASE\"\u003e\u003ccode class=\"token\"\u003eCASE\u003c/code\u003e generic conditional expressions\u003c/a\u003e and parentheses.\u003c/p\u003e\n\u003cp\u003eFunctions and most operators return \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e on \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e input.\u003c/p\u003e\n\u003cp\u003eFor conditional purposes, non zero numerical values are \u003ccode class=\"literal\"\u003eTRUE\u003c/code\u003e, zero numerical values and \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e are \u003ccode class=\"literal\"\u003eFALSE\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eToo large or small integer and double constants, as well as integer arithmetic operators (\u003ccode class=\"literal\"\u003e+\u003c/code\u003e, \u003ccode class=\"literal\"\u003e-\u003c/code\u003e, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e and \u003ccode class=\"literal\"\u003e/\u003c/code\u003e) raise errors on overflows.\u003c/p\u003e\n\u003cp\u003eWhen no final \u003ccode class=\"token\"\u003eELSE\u003c/code\u003e clause is provided to a \u003ccode class=\"token\"\u003eCASE\u003c/code\u003e, the default value is \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set ntellers 10 * :scale\n\\set aid (1021 * random(1, 100000 * :scale)) % \\\n           (100000 * :scale) + 1\n\\set divx CASE WHEN :x \u0026lt;\u0026gt; 0 THEN :y/:x ELSE NULL END\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SLEEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sleep \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [ us | ms | s ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCauses script execution to sleep for the specified duration in microseconds (\u003ccode class=\"literal\"\u003eus\u003c/code\u003e), milliseconds (\u003ccode class=\"literal\"\u003ems\u003c/code\u003e) or seconds (\u003ccode class=\"literal\"\u003es\u003c/code\u003e). If the unit is omitted then seconds are the default. \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e can be either an integer constant or a \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e reference to a variable having an integer value.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\sleep 10 ms\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SETSHELL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\setshell \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e to the result of the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e with the given \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e(s). The command must return an integer value through its standard output.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e and each \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e can be either a text constant or a \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e reference to a variable. If you want to use an \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e starting with a colon, write an additional colon at the beginning of \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\setshell variable_to_be_assigned command literal_argument :variable ::literal_starting_with_colon\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SHELL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\shell \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSame as \u003ccode class=\"literal\"\u003e\\setshell\u003c/code\u003e, but the result of the command is discarded.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\shell command literal_argument :variable ::literal_starting_with_colon\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-PIPELINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\startpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\syncpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endpipeline\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements pipelining of SQL statements. A pipeline must begin with a \u003ccode class=\"command\"\u003e\\startpipeline\u003c/code\u003e and end with an \u003ccode class=\"command\"\u003e\\endpipeline\u003c/code\u003e. In between there may be any number of \u003ccode class=\"command\"\u003e\\syncpipeline\u003c/code\u003e commands, which sends a \u003ca class=\"link\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY\" title=\"54.2.3. Extended Query\"\u003esync message\u003c/a\u003e without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See \u003ca class=\"xref\" href=\"/docs/18/libpq-pipeline-mode.html\" title=\"32.5. Pipeline Mode\"\u003eSection 32.5\u003c/a\u003e for more details. Pipeline mode requires the use of extended query protocol.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-BUILTIN-OPERATORS\"\u003e\n\u003ch3\u003eBuilt-in Operators\u003c/h3\u003e\n\u003cp\u003eThe arithmetic, bitwise, comparison and logical operators listed in \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#PGBENCH-OPERATORS\" title=\"Table 302. pgbench Operators\"\u003eTable 302\u003c/a\u003e are built into \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e and may be used in expressions appearing in \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-METACOMMAND-SET\"\u003e\u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e\u003c/a\u003e. The operators are listed in increasing precedence order. Except as noted, operators taking two numeric inputs will produce a double value if either input is double, otherwise they produce an integer result.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"PGBENCH-OPERATORS\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 302. pgbench Operators\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003eOperator\u003c/p\u003e\n\u003cp\u003eDescription\u003c/p\u003e\n\u003cp\u003eExample(s)\u003c/p\u003e\n\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eOR\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical OR\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 or 0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eAND\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical AND\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e3 and 0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"literal\"\u003eNOT\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical NOT\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003enot false\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eIS [NOT] (NULL|TRUE|FALSE)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBoolean value tests\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 is null\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eISNULL|NOTNULL\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNullness tests\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 notnull\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eEqual\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 = 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;\u0026gt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNot equal\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026lt;\u0026gt; 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e!=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNot equal\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 != 5\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLess than\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026lt; 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLess than or equal to\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026lt;= 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026gt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eGreater than\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026gt; 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026gt;=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eGreater than or equal to\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026gt;= 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e|\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise OR\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 | 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e3\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e#\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise XOR\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 # 3\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026amp;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise AND\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 \u0026amp; 3\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"literal\"\u003e~\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise NOT\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e~ 1\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;\u0026lt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise shift left\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 \u0026lt;\u0026lt; 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e4\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026gt;\u0026gt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise shift right\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e8 \u0026gt;\u0026gt; 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e+\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eAddition\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 + 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e9\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e-\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSubtraction\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e3 - 2.0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e*\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eMultiplication\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 * 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e20\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e/\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eDivision (truncates the result towards zero if both inputs are integers)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 / 3\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e%\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eModulo (remainder)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e3 % 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"literal\"\u003e-\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNegation\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e- 2.0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-2.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-BUILTIN-FUNCTIONS\"\u003e\n\u003ch3\u003eBuilt-In Functions\u003c/h3\u003e\n\u003cp\u003eThe functions listed in \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#PGBENCH-FUNCTIONS\" title=\"Table 303. pgbench Functions\"\u003eTable 303\u003c/a\u003e are built into \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e and may be used in expressions appearing in \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-METACOMMAND-SET\"\u003e\u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"PGBENCH-FUNCTIONS\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 303. pgbench Functions\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003eFunction\u003c/p\u003e\n\u003cp\u003eDescription\u003c/p\u003e\n\u003cp\u003eExample(s)\u003c/p\u003e\n\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eabs\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → same type as input\u003c/p\u003e\n\u003cp\u003eAbsolute value\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eabs(-17)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e17\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003edebug\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → same type as input\u003c/p\u003e\n\u003cp\u003ePrints the argument to \u003cspan class=\"systemitem\"\u003estderr\u003c/span\u003e, and returns the argument.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003edebug(5432.1)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e5432.1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003edouble\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eCasts to double.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003edouble(5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e5432.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eexp\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eExponential (\u003ccode class=\"literal\"\u003ee\u003c/code\u003e raised to the given power)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eexp(1.0)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2.718281828459045\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003egreatest\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003ccode class=\"literal\"\u003e...\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"type\"\u003edouble\u003c/code\u003e if any argument is double, else \u003ccode class=\"type\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSelects the largest value among the arguments.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003egreatest(5, 4, 3, 2)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e5\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003ehash\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eThis is an alias for \u003ccode class=\"function\"\u003ehash_murmur2\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ehash(10, 5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-5817877081768721676\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003ehash_fnv1a\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes \u003ca class=\"ulink\" href=\"https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function\"\u003eFNV-1a hash\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ehash_fnv1a(10, 5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-7793829335365542153\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003ehash_murmur2\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes \u003ca class=\"ulink\" href=\"https://en.wikipedia.org/wiki/MurmurHash\"\u003eMurmurHash2 hash\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ehash_murmur2(10, 5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-5817877081768721676\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eint\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eCasts to integer.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eint(5.4 + 3.8)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e9\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eleast\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003ccode class=\"literal\"\u003e...\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"type\"\u003edouble\u003c/code\u003e if any argument is double, else \u003ccode class=\"type\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSelects the smallest value among the arguments.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eleast(5, 4, 3, 2.1)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2.1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eln\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNatural logarithm\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eln(2.718281828459045)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003emod\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eModulo (remainder)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003emod(54, 32)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e22\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epermute\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e [, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003ePermuted value of \u003cem class=\"parameter\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e, in the range \u003ccode class=\"literal\"\u003e[0, size)\u003c/code\u003e. This is the new position of \u003cem class=\"parameter\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e (modulo \u003cem class=\"parameter\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e) in a pseudorandom permutation of the integers \u003ccode class=\"literal\"\u003e0...size-1\u003c/code\u003e, parameterized by \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epermute(0, 4)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 0 and 3\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epi\u003c/code\u003e () → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eApproximate value of \u003cspan class=\"symbol_font\"\u003eπ\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epi()\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e3.14159265358979323846\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epow\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epower\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e raised to the power of \u003cem class=\"parameter\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epow(2.0, 10)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1024.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a uniformly-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom(1, 10)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom_exponential\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes an exponentially-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_exponential(1, 10, 3.0)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom_gaussian\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a Gaussian-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_gaussian(1, 10, 2.5)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom_zipfian\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a Zipfian-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_zipfian(1, 10, 1.5)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003esqrt\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSquare root\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003esqrt(2.0)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1.414213562\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003erandom\u003c/code\u003e function generates values using a uniform distribution, that is all the values are drawn within the specified range with equal probability. The \u003ccode class=\"literal\"\u003erandom_exponential\u003c/code\u003e, \u003ccode class=\"literal\"\u003erandom_gaussian\u003c/code\u003e and \u003ccode class=\"literal\"\u003erandom_zipfian\u003c/code\u003e functions require an additional double parameter which determines the precise shape of the distribution.\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eFor an exponential distribution, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e controls the distribution by truncating a quickly-decreasing exponential distribution at \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, and then projecting onto integers between the bounds. To be precise, with\u003c/p\u003e\n\u003cdiv class=\"literallayout\"\u003e\n\u003cp\u003e\u003cbr\u003e\n              f(x) = exp(-parameter * (x - min) / (max - min + 1)) / (1 - exp(-parameter))\u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThen value \u003cem class=\"replaceable\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e between \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e inclusive is drawn with probability: \u003ccode class=\"literal\"\u003ef(i) - f(i + 1)\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIntuitively, the larger the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values close to \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e are accessed, and the less frequently values close to \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e are accessed. The closer to 0 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e is, the flatter (more uniform) the access distribution. A crude approximation of the distribution is that the most frequent 1% values in the range, close to \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e, are drawn \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e% of the time. The \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value must be strictly positive.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eFor a Gaussian distribution, the interval is mapped onto a standard normal distribution (the classical bell-shaped Gaussian curve) truncated at \u003ccode class=\"literal\"\u003e-parameter\u003c/code\u003e on the left and \u003ccode class=\"literal\"\u003e+parameter\u003c/code\u003e on the right. Values in the middle of the interval are more likely to be drawn. To be precise, if \u003ccode class=\"literal\"\u003ePHI(x)\u003c/code\u003e is the cumulative distribution function of the standard normal distribution, with mean \u003ccode class=\"literal\"\u003emu\u003c/code\u003e defined as \u003ccode class=\"literal\"\u003e(max + min) / 2.0\u003c/code\u003e, with\u003c/p\u003e\n\u003cdiv class=\"literallayout\"\u003e\n\u003cp\u003e\u003cbr\u003e\n              f(x) = PHI(2.0 * parameter * (x - mu) / (max - min + 1)) /\u003cbr\u003e\n                     (2.0 * PHI(parameter) - 1)\u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003ethen value \u003cem class=\"replaceable\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e between \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e inclusive is drawn with probability: \u003ccode class=\"literal\"\u003ef(i + 0.5) - f(i - 0.5)\u003c/code\u003e. Intuitively, the larger the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values close to the middle of the interval are drawn, and the less frequently values close to the \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e bounds. About 67% of values are drawn from the middle \u003ccode class=\"literal\"\u003e1.0 / parameter\u003c/code\u003e, that is a relative \u003ccode class=\"literal\"\u003e0.5 / parameter\u003c/code\u003e around the mean, and 95% in the middle \u003ccode class=\"literal\"\u003e2.0 / parameter\u003c/code\u003e, that is a relative \u003ccode class=\"literal\"\u003e1.0 / parameter\u003c/code\u003e around the mean; for instance, if \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e is 4.0, 67% of values are drawn from the middle quarter (1.0 / 4.0) of the interval (i.e., from \u003ccode class=\"literal\"\u003e3.0 / 8.0\u003c/code\u003e to \u003ccode class=\"literal\"\u003e5.0 / 8.0\u003c/code\u003e) and 95% from the middle half (\u003ccode class=\"literal\"\u003e2.0 / 4.0\u003c/code\u003e) of the interval (second and third quartiles). The minimum allowed \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value is 2.0.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_zipfian\u003c/code\u003e generates a bounded Zipfian distribution. \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e defines how skewed the distribution is. The larger the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values closer to the beginning of the interval are drawn. The distribution is such that, assuming the range starts from 1, the ratio of the probability of drawing \u003cem class=\"replaceable\"\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e versus drawing \u003cem class=\"replaceable\"\u003e\u003ccode\u003ek+1\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003e((\u003cem class=\"replaceable\"\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e+1)/\u003cem class=\"replaceable\"\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e)**\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. For example, \u003ccode class=\"literal\"\u003erandom_zipfian(1, ..., 2.5)\u003c/code\u003e produces the value \u003ccode class=\"literal\"\u003e1\u003c/code\u003e about \u003ccode class=\"literal\"\u003e(2/1)**2.5 = 5.66\u003c/code\u003e times more frequently than \u003ccode class=\"literal\"\u003e2\u003c/code\u003e, which itself is produced \u003ccode class=\"literal\"\u003e(3/2)**2.5 = 2.76\u003c/code\u003e times more frequently than \u003ccode class=\"literal\"\u003e3\u003c/code\u003e, and so on.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e's implementation is based on \"Non-Uniform Random Variate Generation\", Luc Devroye, p. 550-551, Springer 1986. Due to limitations of that algorithm, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value is restricted to the range [1.001, 1000].\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhen designing a benchmark which selects rows non-uniformly, be aware that the rows chosen may be correlated with other data such as IDs from a sequence or the physical row ordering, which may skew performance measurements.\u003c/p\u003e\n\u003cp\u003eTo avoid this, you may wish to use the \u003ccode class=\"function\"\u003epermute\u003c/code\u003e function, or some other additional step with similar effect, to shuffle the selected rows and remove such correlations.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eHash functions \u003ccode class=\"literal\"\u003ehash\u003c/code\u003e, \u003ccode class=\"literal\"\u003ehash_murmur2\u003c/code\u003e and \u003ccode class=\"literal\"\u003ehash_fnv1a\u003c/code\u003e accept an input value and an optional seed parameter. In case the seed isn't provided the value of \u003ccode class=\"literal\"\u003e:default_seed\u003c/code\u003e is used, which is initialized randomly unless set by the command-line \u003ccode class=\"literal\"\u003e-D\u003c/code\u003e option.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epermute\u003c/code\u003e accepts an input value, a size, and an optional seed parameter. It generates a pseudorandom permutation of integers in the range \u003ccode class=\"literal\"\u003e[0, size)\u003c/code\u003e, and returns the index of the input value in the permuted values. The permutation chosen is parameterized by the seed, which defaults to \u003ccode class=\"literal\"\u003e:default_seed\u003c/code\u003e, if not specified. Unlike the hash functions, \u003ccode class=\"literal\"\u003epermute\u003c/code\u003e ensures that there are no collisions or holes in the output values. Input values outside the interval are interpreted modulo the size. The function raises an error if the size is not positive. \u003ccode class=\"function\"\u003epermute\u003c/code\u003e can be used to scatter the distribution of non-uniform random functions such as \u003ccode class=\"literal\"\u003erandom_zipfian\u003c/code\u003e or \u003ccode class=\"literal\"\u003erandom_exponential\u003c/code\u003e so that values drawn more often are not trivially correlated. For instance, the following \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e script simulates a possible real world workload typical for social media and blogging platforms where a few accounts generate excessive load:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set size 1000000\n\\set r random_zipfian(1, :size, 1.07)\n\\set k 1 + permute(:r, :size)\n\u003c/pre\u003e\n\u003cp\u003eIn some cases several distinct distributions are needed which don't correlate with each other and this is when the optional seed parameter comes in handy:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set k1 1 + permute(:r, :size, :default_seed + 123)\n\\set k2 1 + permute(:r, :size, :default_seed + 321)\n\u003c/pre\u003e\n\u003cp\u003eA similar behavior can also be approximated with \u003ccode class=\"function\"\u003ehash\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set size 1000000\n\\set r random_zipfian(1, 100 * :size, 1.07)\n\\set k 1 + abs(hash(:r)) % :size\n\u003c/pre\u003e\n\u003cp\u003eHowever, since \u003ccode class=\"function\"\u003ehash\u003c/code\u003e generates collisions, some values will not be reachable and others will be more frequent than expected from the original distribution.\u003c/p\u003e\n\u003cp\u003eAs an example, the full definition of the built-in TPC-B-like transaction is:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set aid random(1, 100000 * :scale)\n\\set bid random(1, 1 * :scale)\n\\set tid random(1, 10 * :scale)\n\\set delta random(-5000, 5000)\nBEGIN;\nUPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\nSELECT abalance FROM pgbench_accounts WHERE aid = :aid;\nUPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\nUPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\nINSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\nEND;\n\u003c/pre\u003e\n\u003cp\u003eThis 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 — otherwise they'd not be independently touching different rows.)\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.6\"\u003e\n\u003ch3\u003ePer-Transaction Logging\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode class=\"option\"\u003e-l\u003c/code\u003e option (but without the \u003ccode class=\"option\"\u003e--aggregate-interval\u003c/code\u003e option), \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e writes information about each transaction to a log file. The log file will be named \u003ccode class=\"filename\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e defaults to \u003ccode class=\"literal\"\u003epgbench_log\u003c/code\u003e, and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e is the PID of the \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e process. The prefix can be changed by using the \u003ccode class=\"option\"\u003e--log-prefix\u003c/code\u003e option. If the \u003ccode class=\"option\"\u003e-j\u003c/code\u003e option is 2 or higher, so that there are multiple worker threads, each will have its own log file. The first worker will use the same name for its log file as in the standard single worker case. The additional log files for the other workers will be named \u003ccode class=\"filename\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003emmm\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003emmm\u003c/code\u003e\u003c/em\u003e is a sequential number for each worker starting with 1.\u003c/p\u003e\n\u003cp\u003eEach line in a log file describes one transaction. It contains the following space-separated fields:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eclient_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eidentifies the client session that ran the transaction\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_no\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ecounts how many transactions have been run by that session\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction's elapsed time, in microseconds\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escript_no\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eidentifies the script file that was used for the transaction (useful when multiple scripts are specified with \u003ccode class=\"option\"\u003e-f\u003c/code\u003e or \u003ccode class=\"option\"\u003e-b\u003c/code\u003e)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etime_epoch\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction's completion time, as a Unix-epoch time stamp\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etime_us\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003efractional-second part of transaction's completion time, in microseconds\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschedule_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction start delay, that is the difference between the transaction's scheduled start time and the time it actually started, in microseconds (present only if \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ecount of retries after serialization or deadlock errors during the transaction (present only if \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eWhen both \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e and \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e are used, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e for a skipped transaction will be reported as \u003ccode class=\"literal\"\u003eskipped\u003c/code\u003e. If the transaction ends with a failure, its \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e will be reported as \u003ccode class=\"literal\"\u003efailed\u003c/code\u003e. If you use the \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e option, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e of the failed transaction will be reported as \u003ccode class=\"literal\"\u003eserialization\u003c/code\u003e or \u003ccode class=\"literal\"\u003edeadlock\u003c/code\u003e depending on the type of failure (see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information).\u003c/p\u003e\n\u003cp\u003eHere is a snippet of a log file generated in a single-client run:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e0 199 2241 0 1175850568 995598\n0 200 2465 0 1175850568 998079\n0 201 2513 0 1175850569 608\n0 202 2038 0 1175850569 2663\n\u003c/pre\u003e\n\u003cp\u003eAnother example with \u003ccode class=\"literal\"\u003e--rate=100\u003c/code\u003e and \u003ccode class=\"literal\"\u003e--latency-limit=5\u003c/code\u003e (note the additional \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschedule_lag\u003c/code\u003e\u003c/em\u003e column):\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e0 81 4621 0 1412881037 912698 3005\n0 82 6173 0 1412881037 914578 4304\n0 83 skipped 0 1412881037 914578 5217\n0 83 skipped 0 1412881037 914578 5099\n0 83 4722 0 1412881037 916203 3108\n0 84 4142 0 1412881037 918023 2333\n0 85 2465 0 1412881037 919759 740\n\u003c/pre\u003e\n\u003cp\u003eIn this example, transaction 82 was late, because its latency (6.173 ms) was over the 5 ms limit. The next two transactions were skipped, because they were already late before they were even started.\u003c/p\u003e\n\u003cp\u003eThe following example shows a snippet of a log file with failures and retries, with the maximum number of tries set to 10 (note the additional \u003cem class=\"replaceable\"\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e column):\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e3 0 47423 0 1499414498 34501 3\n3 1 8333 0 1499414498 42848 0\n3 2 8358 0 1499414498 51219 0\n4 0 72345 0 1499414498 59433 6\n1 3 41718 0 1499414498 67879 4\n1 4 8416 0 1499414498 76311 0\n3 3 33235 0 1499414498 84469 3\n0 0 failed 0 1499414498 84905 9\n2 0 failed 0 1499414498 86248 9\n3 4 8307 0 1499414498 92788 0\n\u003c/pre\u003e\n\u003cp\u003eIf the \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e option is used, the type of failure is reported in the \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e like this:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e3 0 47423 0 1499414498 34501 3\n3 1 8333 0 1499414498 42848 0\n3 2 8358 0 1499414498 51219 0\n4 0 72345 0 1499414498 59433 6\n1 3 41718 0 1499414498 67879 4\n1 4 8416 0 1499414498 76311 0\n3 3 33235 0 1499414498 84469 3\n0 0 serialization 0 1499414498 84905 9\n2 0 serialization 0 1499414498 86248 9\n3 4 8307 0 1499414498 92788 0\n\u003c/pre\u003e\n\u003cp\u003eWhen running a long test on hardware that can handle a lot of transactions, the log files can become very large. The \u003ccode class=\"option\"\u003e--sampling-rate\u003c/code\u003e option can be used to log only a random sample of transactions.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.7\"\u003e\n\u003ch3\u003eAggregated Logging\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode class=\"option\"\u003e--aggregate-interval\u003c/code\u003e option, a different format is used for the log files. Each log line describes one aggregation interval. It contains the following space-separated fields:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval_start\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003estart time of the interval, as a Unix-epoch time stamp\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enum_transactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions within the interval\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of transaction latencies\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_latency_2\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of squares of transaction latencies\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emin_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eminimum transaction latency\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emax_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003emaximum transaction latency\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of transaction start delays (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_lag_2\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of squares of transaction start delays (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emin_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eminimum transaction start delay (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emax_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003emaximum transaction start delay (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eskipped\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions skipped because they would have started too late (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e and \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e are specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eretried\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of retried transactions (zero unless \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of retries after serialization or deadlock errors (zero unless \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eserialization_failures\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions that got a serialization error and were not retried afterwards (zero unless \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edeadlock_failures\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions that got a deadlock error and were not retried afterwards (zero unless \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eHere is some example output generated with this option:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003cstrong class=\"userinput\"\u003e\u003ccode\u003epgbench --aggregate-interval=10 --time=20 --client=10 --log --rate=1000 --latency-limit=10 --failures-detailed --max-tries=10 test\u003c/code\u003e\u003c/strong\u003e\n\n1650260552 5178 26171317 177284491527 1136 44462 2647617 7321113867 0 9866 64 7564 28340 4148 0\n1650260562 4808 25573984 220121792172 1171 62083 3037380 9666800914 0 9998 598 7392 26621 4527 0\n\u003c/pre\u003e\n\u003cp\u003eNotice that while the plain (unaggregated) log format shows which script was used for each transaction, the aggregated format does not. Therefore if you need per-script data, you need to aggregate the data on your own.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.8\"\u003e\n\u003ch3\u003ePer-Statement Report\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode class=\"option\"\u003e-r\u003c/code\u003e option, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e collects the following statistics for each statement:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003elatency\u003c/code\u003e — elapsed transaction time for each statement. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e reports an average value of all successful runs of the statement.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eThe number of failures in this statement. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eThe number of retries after a serialization or a deadlock error in this statement. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eThe report displays retry statistics only if the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003cp\u003eAll values are computed for each statement executed by every client and are reported after the benchmark has finished.\u003c/p\u003e\n\u003cp\u003eFor the default script, the output will look similar to this:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003estarting vacuum...end.\ntransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 1\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nnumber of transactions above the 50.0 ms latency limit: 1311/10000 (13.110 %)\nlatency average = 28.488 ms\nlatency stddev = 21.009 ms\ninitial connection time = 69.068 ms\ntps = 346.224794 (without initial connection time)\nstatement latencies in milliseconds and failures:\n   0.012  0  \\set aid random(1, 100000 * :scale)\n   0.002  0  \\set bid random(1, 1 * :scale)\n   0.002  0  \\set tid random(1, 10 * :scale)\n   0.002  0  \\set delta random(-5000, 5000)\n   0.319  0  BEGIN;\n   0.834  0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n   0.641  0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n  11.126  0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n  12.961  0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n   0.634  0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n   1.957  0  END;\n\u003c/pre\u003e\n\u003cp\u003eAnother example of output for the default script using serializable default transaction isolation level (\u003ccode class=\"command\"\u003ePGOPTIONS='-c default_transaction_isolation=serializable' pgbench ...\u003c/code\u003e):\u003c/p\u003e\n\u003cpre class=\"screen\"\u003estarting vacuum...end.\ntransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 1\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 10\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 6317/10000\nnumber of failed transactions: 3683 (36.830%)\nnumber of transactions retried: 7667 (76.670%)\ntotal number of retries: 45339\nnumber of transactions above the 50.0 ms latency limit: 106/6317 (1.678 %)\nlatency average = 17.016 ms\nlatency stddev = 13.283 ms\ninitial connection time = 45.017 ms\ntps = 186.792667 (without initial connection time)\nstatement latencies in milliseconds, failures and retries:\n  0.006     0      0  \\set aid random(1, 100000 * :scale)\n  0.001     0      0  \\set bid random(1, 1 * :scale)\n  0.001     0      0  \\set tid random(1, 10 * :scale)\n  0.001     0      0  \\set delta random(-5000, 5000)\n  0.385     0      0  BEGIN;\n  0.773     0      1  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n  0.624     0      0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n  1.098   320   3762  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n  0.582  3363  41576  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n  0.465     0      0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n  1.933     0      0  END;\n\u003c/pre\u003e\n\u003cp\u003eIf multiple script files are specified, all statistics are reported separately for each script file.\u003c/p\u003e\n\u003cp\u003eNote that collecting the additional timing information needed for per-statement latency computation adds some overhead. This will slow average execution speed and lower the computed TPS. The amount of slowdown varies significantly depending on platform and hardware. Comparing average TPS values with and without latency reporting enabled is a good way to measure if the timing overhead is significant.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"FAILURES-AND-RETRIES\"\u003e\n\u003ch3\u003eFailures and Serialization/Deadlock Retries\u003c/h3\u003e\n\u003cp\u003eWhen executing \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e, there are three main types of errors:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eErrors of the main program. They are the most serious and always result in an immediate exit from \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e with the corresponding error message. They include:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eerrors at the beginning of \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e (e.g. an invalid option value);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eerrors in the initialization mode (e.g. the query to create tables for built-in scripts fails);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eerrors before starting threads (e.g. could not connect to the database server, syntax error in the meta command, thread creation failure);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003einternal \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e errors (which are supposed to never occur...).\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eErrors when the thread manages its clients (e.g. the client could not start a connection to the database server / the socket for connecting the client to the database server has become invalid). In such cases all clients of this thread stop while other threads continue to work. However, \u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e is specified, all of the threads stop immediately in this case.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eDirect client errors. They lead to immediate exit from \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e with the corresponding error message in the case of an internal \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e error (which are supposed to never occur...) or when \u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e is specified. Otherwise in the worst case they only lead to the abortion of the failed client while other clients continue their run (but some client errors are handled without an abortion of the client and reported separately, see below). Later in this section it is assumed that the discussed errors are only the direct client errors and they are not internal \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e errors.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eA client's run is aborted in case of a serious error; for example, the connection with the database server was lost or the end of script was reached without completing the last transaction. In addition, if execution of an SQL or meta command fails for reasons other than serialization or deadlock errors, the client is aborted. Otherwise, if an SQL command fails with serialization or deadlock errors, the client is not aborted. In such cases, the current transaction is rolled back, which also includes setting the client variables as they were before the run of this transaction (it is assumed that one transaction script contains only one transaction; see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#TRANSACTIONS-AND-SCRIPTS\" title=\"What Is the “Transaction” Actually Performed in pgbench?\"\u003eWhat Is the \"Transaction\" Actually Performed in pgbench?\u003c/a\u003e for more information). Transactions with serialization or deadlock errors are repeated after rollbacks until they complete successfully or reach the maximum number of tries (specified by the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option) / the maximum time of retries (specified by the \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e option) / the end of benchmark (specified by the \u003ccode class=\"option\"\u003e--time\u003c/code\u003e option). If the last trial run fails, this transaction will be reported as failed but the client is not aborted and continues to work.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWithout specifying the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option, a transaction will never be retried after a serialization or deadlock error because its default value is 1. Use an unlimited number of tries (\u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e) and the \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e option to limit only the maximum time of tries. You can also use the \u003ccode class=\"option\"\u003e--time\u003c/code\u003e option to limit the benchmark duration under an unlimited number of tries.\u003c/p\u003e\n\u003cp\u003eBe careful when repeating scripts that contain multiple transactions: the script is always retried completely, so successful transactions can be performed several times.\u003c/p\u003e\n\u003cp\u003eBe careful when repeating transactions with shell commands. Unlike the results of SQL commands, the results of shell commands are not rolled back, except for the variable value of the \u003ccode class=\"command\"\u003e\\setshell\u003c/code\u003e command.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThe latency of a successful transaction includes the entire time of transaction execution with rollbacks and retries. The latency is measured only for successful transactions and commands but not for failed transactions or commands.\u003c/p\u003e\n\u003cp\u003eThe main report contains the number of failed transactions. If the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1, the main report also contains statistics related to retries: the total number of retried transactions and total number of retries. The per-script report inherits all these fields from the main report. The per-statement report displays retry statistics only if the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003cp\u003eIf you want to group failures by basic types in per-transaction and aggregation logs, as well as in the main and per-script reports, use the \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e option. If you also want to distinguish all errors and failures (errors without retrying) by type including which limit for retries was exceeded and how much it was exceeded by for the serialization/deadlock failures, use the \u003ccode class=\"option\"\u003e--verbose-errors\u003c/code\u003e option.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.10\"\u003e\n\u003ch3\u003eTable Access Methods\u003c/h3\u003e\n\u003cp\u003eYou may specify the \u003ca class=\"link\" href=\"/docs/18/tableam.html\" title=\"Chapter 62. Table Access Method Interface Definition\"\u003eTable Access Method\u003c/a\u003e for the pgbench tables. The environment variable \u003ccode class=\"envar\"\u003ePGOPTIONS\u003c/code\u003e specifies database configuration options that are passed to PostgreSQL via the command line (See \u003ca class=\"xref\" href=\"/docs/18/config-setting.html#CONFIG-SETTING-SHELL\" title=\"19.1.4. Parameter Interaction via the Shell\"\u003eSection 19.1.4\u003c/a\u003e). For example, a hypothetical default Table Access Method for the tables that pgbench creates called \u003ccode class=\"literal\"\u003ewuzza\u003c/code\u003e can be specified with:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003ePGOPTIONS='-c default_table_access_method=wuzza'\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.11\"\u003e\n\u003ch3\u003eGood Practices\u003c/h3\u003e\n\u003cp\u003eIt is very easy to use \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e to produce completely meaningless numbers. Here are some guidelines to help you get useful results.\u003c/p\u003e\n\u003cp\u003eIn the first place, \u003cspan class=\"emphasis\"\u003e\u003cem\u003enever\u003c/em\u003e\u003c/span\u003e believe any test that runs for only a few seconds. Use the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e option 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.\u003c/p\u003e\n\u003cp\u003eFor the default TPC-B-like test scenario, the initialization scale factor (\u003ccode class=\"option\"\u003e-s\u003c/code\u003e) should be at least as large as the largest number of clients you intend to test (\u003ccode class=\"option\"\u003e-c\u003c/code\u003e); else you'll mostly be measuring update contention. There are only \u003ccode class=\"option\"\u003e-s\u003c/code\u003e rows in the \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e table, and every transaction wants to update one of them, so \u003ccode class=\"option\"\u003e-c\u003c/code\u003e values in excess of \u003ccode class=\"option\"\u003e-s\u003c/code\u003e will undoubtedly result in lots of transactions blocked waiting for other transactions.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003cp\u003eA limitation of \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e is that it can itself become the bottleneck when trying to test a large number of client sessions. This can be alleviated by running \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e on a different machine from the database server, although low network latency will be essential. It might even be useful to run several \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e instances concurrently, on several client machines, against the same database server.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.12\"\u003e\n\u003ch3\u003eSecurity\u003c/h3\u003e\n\u003cp\u003eIf untrusted users have access to a database that has not adopted a \u003ca class=\"link\" href=\"/docs/18/ddl-schemas.html#DDL-SCHEMAS-PATTERNS\" title=\"5.10.6. Usage Patterns\"\u003esecure schema usage pattern\u003c/a\u003e, do not run \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e in that database. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e uses unqualified names and does not manipulate the search path.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"pgbench.html","options":[{"description":"Required to invoke initialization mode.","names":["-i","--initialize"],"signature":"-i --initialize","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-INITIALIZE","summary":"Required to invoke initialization mode."},{"description":"Perform just a selected set of the normal initialization steps. init_steps specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is dtgvp . The available steps are: d (Drop) Drop any existing pgbench tables. t (create Tables) Create the tables used by the standard pgbench scenario, namely pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers . g or G (Generate data, client-side or server-side) Generate data and load it into the standard tables, replacing any data already present. With g (client-side data generation), data is generated in pgbench client and then sent to the server. This uses the client/server bandwidth extensively through a COPY . pgbench uses the FREEZE option to load data into ordinary (non-partition) tables with version 14 or later of PostgreSQL to speed up subsequent VACUUM . Using g causes logging to print one message every 100,000 rows while generating data for all tables. With G (server-side data generation), only small queries are sent from the pgbench client and then data is actually generated in the server. No significant bandwidth is required for this variant, but the server will do more work. Using G causes logging not to print any progress message while generating data. The default initialization behavior uses client-side data generation (equivalent to g ). v (Vacuum) Invoke VACUUM on the standard tables. p (create Primary keys) Create primary key indexes on the standard tables. f (create Foreign keys) Create foreign key constraints between the standard tables. (Note that this step is not performed by default.)","names":["-I init_steps","--init-steps= init_steps"],"signature":"-I init_steps --init-steps= init_steps","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-INIT-STEPS","summary":"Perform just a selected set of the normal initialization steps. init_steps specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is dtgvp . The available steps are:"},{"description":"Create the pgbench_accounts , pgbench_tellers and pgbench_branches tables with the given fillfactor. Default is 100.","names":["-F","--fillfactor="],"signature":"-F fillfactor --fillfactor= fillfactor","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILLFACTOR","summary":"Create the pgbench_accounts , pgbench_tellers and pgbench_branches tables with the given fillfactor. Default is 100."},{"description":"Perform no vacuuming during initialization. (This option suppresses the v initialization step, even if it was specified in -I .)","names":["-n","--no-vacuum"],"signature":"-n --no-vacuum","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-INIT","summary":"Perform no vacuuming during initialization. (This option suppresses the v initialization step, even if it was specified in -I .)"},{"description":"Switch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware). This setting has no effect if G is specified in -I .","names":["-q","--quiet"],"signature":"-q --quiet","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-QUIET","summary":"Switch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware)."},{"description":"Multiply the number of rows generated by the scale factor. For example, -s 100 will create 10,000,000 rows in the pgbench_accounts table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers ( aid columns) will switch to using larger integers ( bigint ), in order to be big enough to hold the range of account identifiers.","names":["-s","--scale="],"signature":"-s scale_factor --scale= scale_factor","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-INIT","summary":"Multiply the number of rows generated by the scale factor. For example, -s 100 will create 10,000,000 rows in the pgbench_accounts table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers ( aid columns) will switch to using larger integers ( bigint ), in order to be big enough to hold the range of account identifiers."},{"description":"Create foreign key constraints between the standard tables. (This option adds the f step to the initialization step sequence, if it is not already present.)","names":["--foreign-keys"],"signature":"--foreign-keys","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-FOREIGN-KEYS","summary":"Create foreign key constraints between the standard tables. (This option adds the f step to the initialization step sequence, if it is not already present.)"},{"description":"Create indexes in the specified tablespace, rather than the default tablespace.","names":["--index-tablespace= index_tablespace"],"signature":"--index-tablespace= index_tablespace","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-INDEX-TABLESPACE","summary":"Create indexes in the specified tablespace, rather than the default tablespace."},{"description":"Create a partitioned pgbench_accounts table with NAME method. Expected values are range or hash . This option requires that --partitions is set to non-zero. If unspecified, default is range .","names":["--partition-method= NAME"],"signature":"--partition-method= NAME","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITION-METHOD","summary":"Create a partitioned pgbench_accounts table with NAME method. Expected values are range or hash . This option requires that --partitions is set to non-zero. If unspecified, default is range ."},{"description":"Create a partitioned pgbench_accounts table with NUM partitions of nearly equal size for the scaled number of accounts. Default is 0 , meaning no partitioning.","names":["--partitions= NUM"],"signature":"--partitions= NUM","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITIONS","summary":"Create a partitioned pgbench_accounts table with NUM partitions of nearly equal size for the scaled number of accounts. Default is 0 , meaning no partitioning."},{"description":"Create tables in the specified tablespace, rather than the default tablespace.","names":["--tablespace= tablespace"],"signature":"--tablespace= tablespace","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-TABLESPACE","summary":"Create tables in the specified tablespace, rather than the default tablespace."},{"description":"Create all tables as unlogged tables, rather than permanent tables.","names":["--unlogged-tables"],"signature":"--unlogged-tables","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-UNLOGGED-TABLES","summary":"Create all tables as unlogged tables, rather than permanent tables."},{"description":"Add the specified built-in script to the list of scripts to be executed. Available built-in scripts are: tpcb-like , simple-update and select-only . Unambiguous prefixes of built-in names are accepted. With the special name list , show the list of built-in scripts and exit immediately. Optionally, write an integer weight after @ to adjust the probability of selecting this script versus other ones. The default weight is 1. See below for details.","names":["-b","--builtin"],"signature":"-b scriptname[@weight] --builtin = scriptname[@weight]","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-BUILTIN","summary":"Add the specified built-in script to the list of scripts to be executed. Available built-in scripts are: tpcb-like , simple-update and select-only . Unambiguous prefixes of built-in names are accepted. With the special name list , show the list of built-in scripts and exit immediately."},{"description":"Number of clients simulated, that is, number of concurrent database sessions. Default is 1.","names":["-c","--client="],"signature":"-c clients --client= clients","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-CLIENT","summary":"Number of clients simulated, that is, number of concurrent database sessions. Default is 1."},{"description":"Establish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead.","names":["-C","--connect"],"signature":"-C --connect","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-CONNECT","summary":"Establish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead."},{"description":"Define a variable for use by a custom script (see below). Multiple -D options are allowed.","names":["-D","--define="],"signature":"-D varname = value --define= varname = value","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEFINE","summary":"Define a variable for use by a custom script (see below). Multiple -D options are allowed."},{"description":"Add a transaction script read from filename to the list of scripts to be executed. Optionally, write an integer weight after @ to adjust the probability of selecting this script versus other ones. The default weight is 1. (To use a script file name that includes an @ character, append a weight so that there is no ambiguity, for example filen@me@1 .) See below for details.","names":["-f","--file="],"signature":"-f filename[@weight] --file= filename[@weight]","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILE","summary":"Add a transaction script read from filename to the list of scripts to be executed."},{"description":"Number of worker threads within pgbench . Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1.","names":["-j","--jobs="],"signature":"-j threads --jobs= threads","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-JOBS","summary":"Number of worker threads within pgbench . Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1."},{"description":"Write information about each transaction to a log file. See below for details.","names":["-l","--log"],"signature":"-l --log","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG","summary":"Write information about each transaction to a log file. See below for details."},{"description":"Transactions that last more than limit milliseconds are counted and reported separately, as late . When throttling is used ( --rate=... ), transactions that lag behind schedule by more than limit ms, and thus have no hope of meeting the latency limit, are not sent to the server at all. They are counted and reported separately as skipped . When the --max-tries option is used, a transaction which fails due to a serialization anomaly or from a deadlock will not be retried if the total time of all its tries is greater than limit ms. To limit only the time of tries and not their number, use --max-tries=0 . By default, the option --max-tries is set to 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions.","names":["-L","--latency-limit="],"signature":"-L limit --latency-limit= limit","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-LATENCY-LIMIT","summary":"Transactions that last more than limit milliseconds are counted and reported separately, as late ."},{"description":"Protocol to use for submitting queries to the server: simple : use simple query protocol. extended : use extended query protocol. prepared : use extended query protocol with prepared statements. In the prepared mode, pgbench reuses the parse analysis result starting from the second query iteration, so pgbench runs faster than in other modes. The default is simple query protocol. (See Chapter 54 for more information.)","names":["-M","--protocol="],"signature":"-M querymode --protocol= querymode","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROTOCOL","summary":"Protocol to use for submitting queries to the server:"},{"description":"Perform no vacuuming before running the test. This option is necessary if you are running a custom test scenario that does not include the standard tables pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers .","names":["-n","--no-vacuum"],"signature":"-n --no-vacuum","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-RUN","summary":"Perform no vacuuming before running the test. This option is necessary if you are running a custom test scenario that does not include the standard tables pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers ."},{"description":"Run built-in simple-update script. Shorthand for -b simple-update .","names":["-N","--skip-some-updates"],"signature":"-N --skip-some-updates","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-SKIP-SOME-UPDATES","summary":"Run built-in simple-update script. Shorthand for -b simple-update ."},{"description":"Show progress report every sec seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling ( -R ), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When --max-tries is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries.","names":["-P","--progress="],"signature":"-P sec --progress= sec","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS","summary":"Show progress report every sec seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling ( -R ), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When --max-tries is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries."},{"description":"Report the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the --max-tries option is not equal to 1.","names":["-r","--report-per-command"],"signature":"-r --report-per-command","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-REPORT-LATENCIES","summary":"Report the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the --max-tries option is not equal to 1."},{"description":"Execute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results. The rate is targeted by starting transactions along a Poisson-distributed schedule time line. The expected start time schedule moves forward based on when the client first started, not when the previous transaction ended. That approach means that when transactions go past their original scheduled end time, it is possible for later ones to catch up again. When throttling is active, the transaction latency reported at the end of the run is calculated from the scheduled start times, so it includes the time each transaction had to wait for the previous transaction to finish. The wait time is called the schedule lag time, and its average and maximum are also reported separately. The transaction latency with respect to the actual transaction start time, i.e., the time spent executing the transaction in the database, can be computed by subtracting the schedule lag time from the reported latency. If --latency-limit is used together with --rate , a transaction can lag behind so much that it is already over the latency limit when the previous transaction ends, because the latency is calculated from the scheduled start time. Such transactions are not sent to the server, but are skipped altogether and counted separately. A high schedule lag time is an indication that the system cannot process transactions at the specified rate, with the chosen number of clients and threads. When the average transaction execution time is longer than the scheduled interval between each transaction, each successive transaction will fall further behind, and the schedule lag time will keep increasing the longer the test run is. When that happens, you will have to reduce the specified transaction rate.","names":["-R","--rate="],"signature":"-R rate --rate= rate","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-RATE","summary":"Execute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results."},{"description":"Report the specified scale factor in pgbench '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 pgbench_branches table. However, when testing only custom benchmarks ( -f option), the scale factor will be reported as 1 unless this option is used.","names":["-s","--scale="],"signature":"-s scale_factor --scale= scale_factor","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-RUN","summary":"Report the specified scale factor in pgbench '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 pgbench_branches table. However, when testing only custom benchmarks ( -f option), the scale factor will be reported as 1 unless this option is used."},{"description":"Run built-in select-only script. Shorthand for -b select-only .","names":["-S","--select-only"],"signature":"-S --select-only","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-SELECT-ONLY","summary":"Run built-in select-only script. Shorthand for -b select-only ."},{"description":"Number of transactions each client runs. Default is 10.","names":["-t","--transactions="],"signature":"-t transactions --transactions= transactions","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-TRANSACTIONS","summary":"Number of transactions each client runs. Default is 10."},{"description":"Run the test for this many seconds, rather than a fixed number of transactions per client. -t and -T are mutually exclusive.","names":["-T","--time="],"signature":"-T seconds --time= seconds","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-TIME","summary":"Run the test for this many seconds, rather than a fixed number of transactions per client. -t and -T are mutually exclusive."},{"description":"Vacuum all four standard tables before running the test. With neither -n nor -v , pgbench will vacuum the pgbench_tellers and pgbench_branches tables, and will truncate pgbench_history .","names":["-v","--vacuum-all"],"signature":"-v --vacuum-all","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-VACUUM-ALL","summary":"Vacuum all four standard tables before running the test. With neither -n nor -v , pgbench will vacuum the pgbench_tellers and pgbench_branches tables, and will truncate pgbench_history ."},{"description":"Length of aggregation interval (in seconds). May be used only with -l option. With this option, the log contains per-interval summary data, as described below.","names":["--aggregate-interval= seconds"],"signature":"--aggregate-interval= seconds","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-AGGREGATE-INTERVAL","summary":"Length of aggregation interval (in seconds). May be used only with -l option. With this option, the log contains per-interval summary data, as described below."},{"description":"Exit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by -t or -T option, and pgbench will print an incomplete results in this case. Note that serialization failures or deadlock failures do not abort the client, so they are not affected by this option. See Failures and Serialization/Deadlock Retries for more information.","names":["--exit-on-abort"],"signature":"--exit-on-abort","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-EXIT-ON-ABORT","summary":"Exit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by -t or -T option, and pgbench will print an incomplete results in this case."},{"description":"Report failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types: serialization failures; deadlock failures; See Failures and Serialization/Deadlock Retries for more information.","names":["--failures-detailed"],"signature":"--failures-detailed","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-FAILURES-DETAILED","summary":"Report failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types:"},{"description":"Set the filename prefix for the log files created by --log . The default is pgbench_log .","names":["--log-prefix= prefix"],"signature":"--log-prefix= prefix","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG-PREFIX","summary":"Set the filename prefix for the log files created by --log . The default is pgbench_log ."},{"description":"Enable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the --latency-limit option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries ( --max-tries=0 ) without --latency-limit or --time . The default value is 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions.","names":["--max-tries= number_of_tries"],"signature":"--max-tries= number_of_tries","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-MAX-TRIES","summary":"Enable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the --latency-limit option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries ( --max-tries=0 ) without --latency-limit or --time . The default value is 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions."},{"description":"When showing progress (option -P ), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools.","names":["--progress-timestamp"],"signature":"--progress-timestamp","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS-TIMESTAMP","summary":"When showing progress (option -P ), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools."},{"description":"Set random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for seed may be: time (the default, the seed is based on the current time), rand (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script ( random... functions) or implicitly (for instance option --rate uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for seed may also be provided through the environment variable PGBENCH_RANDOM_SEED . To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable. Setting the seed explicitly allows to reproduce a pgbench run exactly, as far as random numbers are concerned. As the random state is managed per thread, this means the exact same pgbench run for an identical invocation if there is one client per thread and there are no external or data dependencies. From a statistical viewpoint reproducing runs exactly is a bad idea because it can hide the performance variability or improve performance unduly, e.g., by hitting the same pages as a previous run. However, it may also be of great help for debugging, for instance re-running a tricky case which leads to an error. Use wisely.","names":["--random-seed="],"signature":"--random-seed= seed","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-RANDOM-SEED","summary":"Set random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for seed may be: time (the default, the seed is based on the current time), rand (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script ( random... functions) or implicitly (for instance option --rate uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for seed may also be provided through the environment variable PGBENCH_RANDOM_SEED . To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable."},{"description":"Sampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged. Remember to take the sampling rate into account when processing the log file. For example, when computing TPS values, you need to multiply the numbers accordingly (e.g., with 0.01 sample rate, you'll only get 1/100 of the actual TPS).","names":["--sampling-rate= rate"],"signature":"--sampling-rate= rate","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-SAMPLING-RATE","summary":"Sampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged."},{"description":"Show the actual code of builtin script scriptname on stderr, and exit immediately.","names":["--show-script="],"signature":"--show-script= scriptname","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-SHOW-SCRIPT","summary":"Show the actual code of builtin script scriptname on stderr, and exit immediately."},{"description":"Print messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See Failures and Serialization/Deadlock Retries for more information.","names":["--verbose-errors"],"signature":"--verbose-errors","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERBOSE-ERRORS","summary":"Print messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See Failures and Serialization/Deadlock Retries for more information."},{"description":"Print debugging output.","names":["--debug"],"signature":"--debug","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEBUG","summary":"Print debugging output."},{"description":"The database server's host name","names":["-h","--host="],"signature":"-h hostname --host= hostname","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-HOST","summary":"The database server's host name"},{"description":"The database server's port number","names":["-p","--port="],"signature":"-p port --port= port","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-PORT","summary":"The database server's port number"},{"description":"The user name to connect as","names":["-U","--username="],"signature":"-U login --username= login","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-USERNAME","summary":"The user name to connect as"},{"description":"Print the pgbench version and exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERSION","summary":"Print the pgbench version and exit."},{"description":"Show help about pgbench command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/pgbench.html#PGBENCH-OPTION-HELP","summary":"Show help about pgbench command line arguments, and exit."}],"related":[],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"sections_zh":[],"signature":"pgbench -i [ option ...] [ dbname ]\npgbench [ option ...] [ dbname ]","sources":[{"anchor":"","file":"pgbench.html","label":"18.6 English manual · pgbench.html","sha256":"b9c9e5f08998320a7ecce6cb615b5eeddc7ef3d0cb5e6c4e3422f3d44c089004","url":"/docs/18/pgbench.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}],"synopsis":["pgbench -i [ option ...] [ dbname ]","pgbench [ option ...] [ dbname ]"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-i --initialize","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INITIALIZE"},"summary":"Required to invoke initialization mode."},{"signature":{"text":"-I init_steps --init-steps= init_steps","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INIT-STEPS"},"summary":"Perform just a selected set of the normal initialization steps. init_steps specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is dtgvp . The available steps are:"},{"signature":{"text":"-F fillfactor --fillfactor= fillfactor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILLFACTOR"},"summary":"Create the pgbench_accounts , pgbench_tellers and pgbench_branches tables with the given fillfactor. Default is 100."},{"signature":{"text":"-n --no-vacuum","url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-INIT"},"summary":"Perform no vacuuming during initialization. (This option suppresses the v initialization step, even if it was specified in -I .)"},{"signature":{"text":"-q --quiet","url":"/docs/18/pgbench.html#PGBENCH-OPTION-QUIET"},"summary":"Switch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware)."},{"signature":{"text":"-s scale_factor --scale= scale_factor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-INIT"},"summary":"Multiply the number of rows generated by the scale factor. For example, -s 100 will create 10,000,000 rows in the pgbench_accounts table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers ( aid columns) will switch to using larger integers ( bigint ), in order to be big enough to hold the range of account identifiers."},{"signature":{"text":"--foreign-keys","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FOREIGN-KEYS"},"summary":"Create foreign key constraints between the standard tables. (This option adds the f step to the initialization step sequence, if it is not already present.)"},{"signature":{"text":"--index-tablespace= index_tablespace","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INDEX-TABLESPACE"},"summary":"Create indexes in the specified tablespace, rather than the default tablespace."},{"signature":{"text":"--partition-method= NAME","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITION-METHOD"},"summary":"Create a partitioned pgbench_accounts table with NAME method. Expected values are range or hash . This option requires that --partitions is set to non-zero. If unspecified, default is range ."},{"signature":{"text":"--partitions= NUM","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITIONS"},"summary":"Create a partitioned pgbench_accounts table with NUM partitions of nearly equal size for the scaled number of accounts. Default is 0 , meaning no partitioning."},{"signature":{"text":"--tablespace= tablespace","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TABLESPACE"},"summary":"Create tables in the specified tablespace, rather than the default tablespace."},{"signature":{"text":"--unlogged-tables","url":"/docs/18/pgbench.html#PGBENCH-OPTION-UNLOGGED-TABLES"},"summary":"Create all tables as unlogged tables, rather than permanent tables."},{"signature":{"text":"-b scriptname[@weight] --builtin = scriptname[@weight]","url":"/docs/18/pgbench.html#PGBENCH-OPTION-BUILTIN"},"summary":"Add the specified built-in script to the list of scripts to be executed. Available built-in scripts are: tpcb-like , simple-update and select-only . Unambiguous prefixes of built-in names are accepted. With the special name list , show the list of built-in scripts and exit immediately."},{"signature":{"text":"-c clients --client= clients","url":"/docs/18/pgbench.html#PGBENCH-OPTION-CLIENT"},"summary":"Number of clients simulated, that is, number of concurrent database sessions. Default is 1."},{"signature":{"text":"-C --connect","url":"/docs/18/pgbench.html#PGBENCH-OPTION-CONNECT"},"summary":"Establish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead."},{"signature":{"text":"-D varname = value --define= varname = value","url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEFINE"},"summary":"Define a variable for use by a custom script (see below). Multiple -D options are allowed."},{"signature":{"text":"-f filename[@weight] --file= filename[@weight]","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILE"},"summary":"Add a transaction script read from filename to the list of scripts to be executed."},{"signature":{"text":"-j threads --jobs= threads","url":"/docs/18/pgbench.html#PGBENCH-OPTION-JOBS"},"summary":"Number of worker threads within pgbench . Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1."},{"signature":{"text":"-l --log","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG"},"summary":"Write information about each transaction to a log file. See below for details."},{"signature":{"text":"-L limit --latency-limit= limit","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LATENCY-LIMIT"},"summary":"Transactions that last more than limit milliseconds are counted and reported separately, as late ."},{"signature":{"text":"-M querymode --protocol= querymode","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROTOCOL"},"summary":"Protocol to use for submitting queries to the server:"},{"signature":{"text":"-n --no-vacuum","url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-RUN"},"summary":"Perform no vacuuming before running the test. This option is necessary if you are running a custom test scenario that does not include the standard tables pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers ."},{"signature":{"text":"-N --skip-some-updates","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SKIP-SOME-UPDATES"},"summary":"Run built-in simple-update script. Shorthand for -b simple-update ."},{"signature":{"text":"-P sec --progress= sec","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS"},"summary":"Show progress report every sec seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling ( -R ), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When --max-tries is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries."},{"signature":{"text":"-r --report-per-command","url":"/docs/18/pgbench.html#PGBENCH-OPTION-REPORT-LATENCIES"},"summary":"Report the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the --max-tries option is not equal to 1."},{"signature":{"text":"-R rate --rate= rate","url":"/docs/18/pgbench.html#PGBENCH-OPTION-RATE"},"summary":"Execute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results."},{"signature":{"text":"-s scale_factor --scale= scale_factor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-RUN"},"summary":"Report the specified scale factor in pgbench '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 pgbench_branches table. However, when testing only custom benchmarks ( -f option), the scale factor will be reported as 1 unless this option is used."},{"signature":{"text":"-S --select-only","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SELECT-ONLY"},"summary":"Run built-in select-only script. Shorthand for -b select-only ."},{"signature":{"text":"-t transactions --transactions= transactions","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TRANSACTIONS"},"summary":"Number of transactions each client runs. Default is 10."},{"signature":{"text":"-T seconds --time= seconds","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TIME"},"summary":"Run the test for this many seconds, rather than a fixed number of transactions per client. -t and -T are mutually exclusive."},{"signature":{"text":"-v --vacuum-all","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VACUUM-ALL"},"summary":"Vacuum all four standard tables before running the test. With neither -n nor -v , pgbench will vacuum the pgbench_tellers and pgbench_branches tables, and will truncate pgbench_history ."},{"signature":{"text":"--aggregate-interval= seconds","url":"/docs/18/pgbench.html#PGBENCH-OPTION-AGGREGATE-INTERVAL"},"summary":"Length of aggregation interval (in seconds). May be used only with -l option. With this option, the log contains per-interval summary data, as described below."},{"signature":{"text":"--exit-on-abort","url":"/docs/18/pgbench.html#PGBENCH-OPTION-EXIT-ON-ABORT"},"summary":"Exit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by -t or -T option, and pgbench will print an incomplete results in this case."},{"signature":{"text":"--failures-detailed","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FAILURES-DETAILED"},"summary":"Report failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types:"},{"signature":{"text":"--log-prefix= prefix","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG-PREFIX"},"summary":"Set the filename prefix for the log files created by --log . The default is pgbench_log ."},{"signature":{"text":"--max-tries= number_of_tries","url":"/docs/18/pgbench.html#PGBENCH-OPTION-MAX-TRIES"},"summary":"Enable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the --latency-limit option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries ( --max-tries=0 ) without --latency-limit or --time . The default value is 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions."},{"signature":{"text":"--progress-timestamp","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS-TIMESTAMP"},"summary":"When showing progress (option -P ), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools."},{"signature":{"text":"--random-seed= seed","url":"/docs/18/pgbench.html#PGBENCH-OPTION-RANDOM-SEED"},"summary":"Set random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for seed may be: time (the default, the seed is based on the current time), rand (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script ( random... functions) or implicitly (for instance option --rate uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for seed may also be provided through the environment variable PGBENCH_RANDOM_SEED . To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable."},{"signature":{"text":"--sampling-rate= rate","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SAMPLING-RATE"},"summary":"Sampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged."},{"signature":{"text":"--show-script= scriptname","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SHOW-SCRIPT"},"summary":"Show the actual code of builtin script scriptname on stderr, and exit immediately."},{"signature":{"text":"--verbose-errors","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERBOSE-ERRORS"},"summary":"Print messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See Failures and Serialization/Deadlock Retries for more information."},{"signature":{"text":"--debug","url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEBUG"},"summary":"Print debugging output."},{"signature":{"text":"-h hostname --host= hostname","url":"/docs/18/pgbench.html#PGBENCH-OPTION-HOST"},"summary":"The database server's host name"},{"signature":{"text":"-p port --port= port","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PORT"},"summary":"The database server's port number"},{"signature":{"text":"-U login --username= login","url":"/docs/18/pgbench.html#PGBENCH-OPTION-USERNAME"},"summary":"The user name to connect as"},{"signature":{"text":"-V --version","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERSION"},"summary":"Print the pgbench version and exit."},{"signature":{"text":"-? --help","url":"/docs/18/pgbench.html#PGBENCH-OPTION-HELP"},"summary":"Show help about pgbench command line arguments, and exit."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Default connection parameters.","name":"PGDATABASE PGHOST PGPORT PGUSER"}],"title":"Environment variables"}],"tables_zh":[{"columns":[{"key":"signature","label":"选项与参数"},{"key":"summary","label":"说明"}],"key":"options","rows":[{"signature":{"text":"-i --initialize","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INITIALIZE"},"summary":"进入初始化模式所必需。"},{"signature":{"text":"-I init_steps --init-steps= init_steps","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INIT-STEPS"},"summary":"仅执行正常初始化步骤中的选定部分。 init_steps 指定要执行的初始化步骤，每个步骤用一个字符表示。各步骤会按照指定顺序调用。默认值为 dtgvp 。可用步骤如下："},{"signature":{"text":"-F fillfactor --fillfactor= fillfactor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILLFACTOR"},"summary":"使用给定的 fillfactor 创建 pgbench_accounts、pgbench_tellers 和 pgbench_branches 表。默认值为 100。"},{"signature":{"text":"-n --no-vacuum","url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-INIT"},"summary":"初始化期间不执行清理。（此选项会抑制 v 初始化步骤，即使 -I 中已指定该步骤。）"},{"signature":{"text":"-q --quiet","url":"/docs/18/pgbench.html#PGBENCH-OPTION-QUIET"},"summary":"将日志切换为静默模式，每 5 秒只输出一条进度消息。默认日志每生成 100,000 行输出一条消息，因而往往会在每秒输出多行（尤其是在较好的硬件上）。"},{"signature":{"text":"-s scale_factor --scale= scale_factor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-INIT"},"summary":"将生成的行数乘以规模因子。例如，-s 100 会在 pgbench_accounts 表中创建 10,000,000 行。默认值为 1。当规模因子达到 20,000 或更大时，存放账户标识符的列（aid 列）会改用更大的整数类型（bigint），以容纳所需的账户标识符范围。"},{"signature":{"text":"--foreign-keys","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FOREIGN-KEYS"},"summary":"在标准表之间创建外键约束。（如果初始化步骤序列中尚未包含 f 步骤，则此选项会把它加入进去。）"},{"signature":{"text":"--index-tablespace= index_tablespace","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INDEX-TABLESPACE"},"summary":"在指定的表空间中创建索引，而不是默认的表空间。"},{"signature":{"text":"--partition-method= NAME","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITION-METHOD"},"summary":"使用 NAME 方法创建分区的 pgbench_accounts 表。可选值为 range 或 hash。此选项要求 --partitions 为非零值。未指定时默认为 range。"},{"signature":{"text":"--partitions= NUM","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITIONS"},"summary":"为按规模因子确定的账户数量创建具有 NUM 个分区的 pgbench_accounts 表，各分区大小大致相等。默认值为 0，表示不分区。"},{"signature":{"text":"--tablespace= tablespace","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TABLESPACE"},"summary":"在指定的表空间中创建表，而不是默认的表空间。"},{"signature":{"text":"--unlogged-tables","url":"/docs/18/pgbench.html#PGBENCH-OPTION-UNLOGGED-TABLES"},"summary":"将所有表创建为不记录 WAL 的表，而不是永久表。"},{"signature":{"text":"-b scriptname[@weight] --builtin = scriptname[@weight]","url":"/docs/18/pgbench.html#PGBENCH-OPTION-BUILTIN"},"summary":"将指定的内置脚本添加到待执行脚本列表中。可用的内置脚本包括： tpcb-like 、 simple-update 和 select-only 。也接受内置名称的无歧义前缀。使用特殊名称 list 时，会显示内置脚本列表并立即退出。"},{"signature":{"text":"-c clients --client= clients","url":"/docs/18/pgbench.html#PGBENCH-OPTION-CLIENT"},"summary":"模拟的客户端数量，即并发数据库会话数。默认值为 1。"},{"signature":{"text":"-C --connect","url":"/docs/18/pgbench.html#PGBENCH-OPTION-CONNECT"},"summary":"为每个事务建立一个新连接，而不是仅在每个客户端会话中执行一次。这对于测量连接开销很有用。"},{"signature":{"text":"-D varname = value --define= varname = value","url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEFINE"},"summary":"定义一个变量，供自定义脚本使用（见下文）。允许使用多个 -D 选项。"},{"signature":{"text":"-f filename[@weight] --file= filename[@weight]","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILE"},"summary":"将从 filename 读取的事务脚本添加到要执行的脚本列表中。"},{"signature":{"text":"-j threads --jobs= threads","url":"/docs/18/pgbench.html#PGBENCH-OPTION-JOBS"},"summary":"pgbench 内部的工作线程数。在多 CPU 机器上，使用多个线程可能有帮助。客户端会尽可能均匀地分配到可用线程中。默认值为 1。"},{"signature":{"text":"-l --log","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG"},"summary":"将每个事务的信息写入日志文件。详情见下文。"},{"signature":{"text":"-L limit --latency-limit= limit","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LATENCY-LIMIT"},"summary":"持续时间超过 limit 毫秒的事务会被单独计数和报告，称为 late 。"},{"signature":{"text":"-M querymode --protocol= querymode","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROTOCOL"},"summary":"用于向服务器提交查询的协议："},{"signature":{"text":"-n --no-vacuum","url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-RUN"},"summary":"在运行测试前不执行任何清理。如果运行的是不包含标准表 pgbench_accounts 、 pgbench_branches 、 pgbench_history 和 pgbench_tellers 的自定义测试场景，则此选项是 必需的 。"},{"signature":{"text":"-N --skip-some-updates","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SKIP-SOME-UPDATES"},"summary":"运行内置的 simple-update 脚本。是 -b simple-update 的简写。"},{"signature":{"text":"-P sec --progress= sec","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS"},"summary":"每 sec 秒显示一次进度报告。报告包括自运行开始以来的时间、自上次报告以来的 TPS、自上次报告以来事务延迟的平均值和标准差，以及失败事务数。使用限流（ -R ）时，延迟是相对于事务计划开始时间计算的，而不是实际开始时间，因此其中也包含平均计划滞后时间。当使用 --max-tries 启用事务在串行化/死锁错误后的重试时，报告还会包含发生过重试的事务数以及总重试次数。"},{"signature":{"text":"-r --report-per-command","url":"/docs/18/pgbench.html#PGBENCH-OPTION-REPORT-LATENCIES"},"summary":"基准测试结束后，为每条命令报告以下统计信息：每条语句的平均延迟（从客户端角度衡量的执行时间）、失败次数，以及该命令发生序列化错误或死锁后的重试次数。只有 --max-tries 选项不等于 1 时，报告才会显示重试统计。"},{"signature":{"text":"-R rate --rate= rate","url":"/docs/18/pgbench.html#PGBENCH-OPTION-RATE"},"summary":"以指定速率执行事务，而不是像默认行为那样尽可能快地运行。速率以每秒事务数表示。如果目标速率高于可达到的最大速率，则速率限制不会影响结果。"},{"signature":{"text":"-s scale_factor --scale= scale_factor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-RUN"},"summary":"在 pgbench 输出中报告指定的比例因子。对于内置测试，这没有必要；系统会通过统计 pgbench_branches 表中的行数来检测正确的比例因子。但在只测试自定义基准（ -f 选项）时，除非使用此选项，否则比例因子会被报告为 1。"},{"signature":{"text":"-S --select-only","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SELECT-ONLY"},"summary":"运行内置的 select-only 脚本。是 -b select-only 的简写。"},{"signature":{"text":"-t transactions --transactions= transactions","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TRANSACTIONS"},"summary":"每个客户端运行的事务数量。默认值为10。"},{"signature":{"text":"-T seconds --time= seconds","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TIME"},"summary":"让测试运行指定的秒数，而不是让每个客户端执行固定数量的事务。 -t 和 -T 是互斥的。"},{"signature":{"text":"-v --vacuum-all","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VACUUM-ALL"},"summary":"在运行测试之前，对四个标准表全部执行清理。如果既不使用 -n 也不使用 -v ， pgbench 会对 pgbench_tellers 和 pgbench_branches 表进行清理，并截断 pgbench_history 。"},{"signature":{"text":"--aggregate-interval= seconds","url":"/docs/18/pgbench.html#PGBENCH-OPTION-AGGREGATE-INTERVAL"},"summary":"聚合间隔的长度（以秒为单位）。只能与 -l 选项一起使用。使用此选项时，日志包含每个间隔的摘要数据，如下所述。"},{"signature":{"text":"--exit-on-abort","url":"/docs/18/pgbench.html#PGBENCH-OPTION-EXIT-ON-ABORT"},"summary":"当任一客户端因错误被中止时，立即退出。如果不指定该选项，即使某个客户端被中止，其他客户端仍可按 -t 或 -T 的设定继续运行，此时 pgbench 会输出不完整的结果。"},{"signature":{"text":"--failures-detailed","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FAILURES-DETAILED"},"summary":"在逐事务日志、聚合日志以及主报告和逐脚本报告中，按以下类型分组报告失败："},{"signature":{"text":"--log-prefix= prefix","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG-PREFIX"},"summary":"设置由 --log 创建的日志文件的文件名前缀。默认值为 pgbench_log 。"},{"signature":{"text":"--max-tries= number_of_tries","url":"/docs/18/pgbench.html#PGBENCH-OPTION-MAX-TRIES"},"summary":"为发生序列化错误或死锁的事务启用重试，并设置最大尝试次数。此选项可以与 --latency-limit 一起使用，后者限制同一事务所有尝试的总耗时；此外，只有指定 --latency-limit 或 --time，才允许使用无限尝试次数（--max-tries=0）。默认值为 1，发生序列化错误或死锁的事务不会重试。有关此类事务重试的更多信息，参见“失败与序列化／死锁重试”。"},{"signature":{"text":"--progress-timestamp","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS-TIMESTAMP"},"summary":"显示进度（选项 -P ）时，使用时间戳（Unix 纪元）而不是自运行开始以来的秒数。单位为秒，小数点后精确到毫秒。这有助于比较各种工具生成的日志。"},{"signature":{"text":"--random-seed= seed","url":"/docs/18/pgbench.html#PGBENCH-OPTION-RANDOM-SEED"},"summary":"设置随机数生成器种子。它会先为系统随机数生成器设种，再生成一系列初始生成器状态，每个线程一个。 seed 的取值可以是： time （默认值，种子基于当前时间）， rand （使用强随机源，如果没有可用的则失败），或者无符号十进制整数值。随机生成器既可以在 pgbench 脚本中显式调用（ random... 函数），也可以隐式调用（例如选项 --rate 用于调度事务）。显式设置时，实际用于设种的值会显示在终端上。任何允许的 seed 值也可以通过环境变量 PGBENCH_RANDOM_SEED 提供。为确保提供的种子影响所有可能的用途，将此选项放在第一位或使用环境变量。"},{"signature":{"text":"--sampling-rate= rate","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SAMPLING-RATE"},"summary":"写入日志时使用的采样率，用于减少生成的日志量。如果给定此选项，则只记录指定比例的事务。1.0 表示记录全部事务，0.05 表示只记录 5% 的事务。"},{"signature":{"text":"--show-script= scriptname","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SHOW-SCRIPT"},"summary":"将内置脚本 scriptname 的实际代码输出到 stderr，然后立即退出。"},{"signature":{"text":"--verbose-errors","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERBOSE-ERRORS"},"summary":"打印关于所有错误和失败（不再重试的错误）的消息，包括超出了哪一种重试限制，以及对于串行化/死锁失败超出的幅度。（请注意，这种情况下输出量可能会显著增加。）更多信息见 失败和串行化/死锁重试 。"},{"signature":{"text":"--debug","url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEBUG"},"summary":"打印调试输出。"},{"signature":{"text":"-h hostname --host= hostname","url":"/docs/18/pgbench.html#PGBENCH-OPTION-HOST"},"summary":"数据库服务器的主机名。"},{"signature":{"text":"-p port --port= port","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PORT"},"summary":"数据库服务器的端口号。"},{"signature":{"text":"-U login --username= login","url":"/docs/18/pgbench.html#PGBENCH-OPTION-USERNAME"},"summary":"连接时使用的用户名。"},{"signature":{"text":"-V --version","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERSION"},"summary":"打印 pgbench 版本并退出。"},{"signature":{"text":"-? --help","url":"/docs/18/pgbench.html#PGBENCH-OPTION-HELP"},"summary":"显示 pgbench 命令行参数的帮助信息并退出。"}],"title":"手册中的选项"},{"columns":[{"key":"name","label":"变量"},{"key":"description","label":"含义"}],"key":"environment","rows":[{"description":"默认连接参数。","name":"PGDATABASE PGHOST PGPORT PGUSER"}],"title":"环境变量"}],"zh_from":{"authored_translation":"source-derived-identity","body_sha256":"bf1907e925a7eef3ad32f9753473714a08f32ab22809f443d582dc670206ecb7","kind":"same-version-chinese-manual-with-source-derived-identity","manual":{"anchor":"","build_id":107,"extraction":"command-description-and-options","fragment_sha256":"ada6c308227e07e225da26fd641ca4b605d7b707287e73c20ea7e237e1895079","locale":"zh-Hans","page_key":"pgbench.html","source_hash":"ece734a00fce059ca8df8c9a95ed94e050e0ee4a2e7975d3c3ac22c626e580a4","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/pgbench.html","version":"18"},"runtime_rerun":false,"source_facts_revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}},"ManualEvidence":{"manual_path":"pgbench.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"pgbench.html","label":"18.6 English manual · pgbench.html","sha256":"b9c9e5f08998320a7ecce6cb615b5eeddc7ef3d0cb5e6c4e3422f3d44c089004","url":"/docs/18/pgbench.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"pgbench","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pgbench","Summary":"pgbench — run a benchmark test on PostgreSQL","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"PGBENCH\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epgbench\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epgbench — run a benchmark test on \u003cspan\u003ePostgreSQL\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.4.11.4.1\"\u003e\u003ccode\u003epgbench\u003c/code\u003e \u003ccode\u003e-i\u003c/code\u003e [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.4.11.4.2\"\u003e\u003ccode\u003epgbench\u003c/code\u003e [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e is a simple program for running benchmark tests on \u003cspan\u003ePostgreSQL\u003c/span\u003e. 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, \u003cspan\u003epgbench\u003c/span\u003e tests a scenario that is loosely based on TPC-B, involving five \u003ccode\u003eSELECT\u003c/code\u003e, \u003ccode\u003eUPDATE\u003c/code\u003e, and \u003ccode\u003eINSERT\u003c/code\u003e commands per transaction. However, it is easy to test other cases by writing your own transaction script files.\u003c/p\u003e\n\u003cp\u003eTypical output from \u003cspan\u003epgbench\u003c/span\u003e looks like:\u003c/p\u003e\n\u003cpre\u003etransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 10\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nlatency average = 11.013 ms\nlatency stddev = 7.351 ms\ninitial connection time = 45.758 ms\ntps = 896.967014 (without initial connection time)\n\u003c/pre\u003e\n\u003cp\u003eThe first seven lines report some of the most important parameter settings. The sixth line reports the maximum number of tries for transactions with serialization or deadlock errors (see \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information). The eighth line reports the number of transactions completed and intended (the latter being just the product of number of clients and number of transactions per client); these will be equal unless the run failed before completion or some SQL command(s) failed. (In \u003ccode\u003e-T\u003c/code\u003e mode, only the actual number of transactions is printed.) The next line reports the number of failed transactions due to serialization or deadlock errors (see \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information). The last line reports the number of transactions per second.\u003c/p\u003e\n\u003cp\u003eThe default TPC-B-like transaction test requires specific tables to be set up beforehand. \u003cspan\u003epgbench\u003c/span\u003e should be invoked with the \u003ccode\u003e-i\u003c/code\u003e (initialize) option to create and populate these tables. (When you are testing a custom script, you don\u0026#39;t need this step, but will instead need to do whatever setup your test needs.) Initialization looks like:\u003c/p\u003e\n\u003cpre\u003epgbench -i [\u003cspan\u003e \u003cem\u003e\u003ccode\u003eother-options\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003ewhere \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e is the name of the already-created database to test in. (You may also need \u003ccode\u003e-h\u003c/code\u003e, \u003ccode\u003e-p\u003c/code\u003e, and/or \u003ccode\u003e-U\u003c/code\u003e options to specify how to connect to the database server.)\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eCaution\u003c/h3\u003e\n\u003cp\u003e\u003ccode\u003epgbench -i\u003c/code\u003e creates four tables \u003ccode\u003epgbench_accounts\u003c/code\u003e, \u003ccode\u003epgbench_branches\u003c/code\u003e, \u003ccode\u003epgbench_history\u003c/code\u003e, and \u003ccode\u003epgbench_tellers\u003c/code\u003e, destroying any existing tables of these names. Be very careful to use another database if you have tables having these names!\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eAt the default \u003cspan\u003e“\u003cspan\u003escale factor\u003c/span\u003e”\u003c/span\u003e of 1, the tables initially contain this many rows:\u003c/p\u003e\n\u003cpre\u003etable                   # of rows\n---------------------------------\npgbench_branches        1\npgbench_tellers         10\npgbench_accounts        100000\npgbench_history         0\n\u003c/pre\u003e\n\u003cp\u003eYou can (and, for most purposes, probably should) increase the number of rows by using the \u003ccode\u003e-s\u003c/code\u003e (scale factor) option. The \u003ccode\u003e-F\u003c/code\u003e (fillfactor) option might also be used at this point.\u003c/p\u003e\n\u003cp\u003eOnce you have done the necessary setup, you can run your benchmark with a command that doesn\u0026#39;t include \u003ccode\u003e-i\u003c/code\u003e, that is\u003c/p\u003e\n\u003cpre\u003epgbench [\u003cspan\u003e \u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003eIn nearly all cases, you\u0026#39;ll need some options to make a useful test. The most important options are \u003ccode\u003e-c\u003c/code\u003e (number of clients), \u003ccode\u003e-t\u003c/code\u003e (number of transactions), \u003ccode\u003e-T\u003c/code\u003e (time limit), and \u003ccode\u003e-f\u003c/code\u003e (specify a custom script file). See below for a full list.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003eThe following is divided into three subsections. Different options are used during database initialization and while running benchmarks, but some options are useful in both cases.\u003c/p\u003e\n\u003cdiv id=\"PGBENCH-INIT-OPTIONS\"\u003e\n\u003ch3\u003eInitialization Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e accepts the following command-line initialization arguments:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"PGBENCH-OPTION-DBNAME\"\u003e\u003cspan\u003e\u003ccode\u003e[\u003cspan\u003e-d\u003c/span\u003e] \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e[\u003cspan\u003e--dbname=\u003c/span\u003e]\u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the name of the database to test in. If this is not specified, the environment variable \u003ccode\u003ePGDATABASE\u003c/code\u003e is used. If that is not set, the user name specified for the connection is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INITIALIZE\"\u003e\u003cspan\u003e\u003ccode\u003e-i\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--initialize\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequired to invoke initialization mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS\"\u003e\u003cspan\u003e\u003ccode\u003e-I \u003cem\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--init-steps=\u003cem\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform just a selected set of the normal initialization steps. \u003cem\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is \u003ccode\u003edtgvp\u003c/code\u003e. The available steps are:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-D\"\u003e\u003cspan\u003e\u003ccode\u003ed\u003c/code\u003e (Drop)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDrop any existing \u003cspan\u003epgbench\u003c/span\u003e tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-T\"\u003e\u003cspan\u003e\u003ccode\u003et\u003c/code\u003e (create Tables)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate the tables used by the standard \u003cspan\u003epgbench\u003c/span\u003e scenario, namely \u003ccode\u003epgbench_accounts\u003c/code\u003e, \u003ccode\u003epgbench_branches\u003c/code\u003e, \u003ccode\u003epgbench_history\u003c/code\u003e, and \u003ccode\u003epgbench_tellers\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-G\"\u003e\u003cspan\u003e\u003ccode\u003eg\u003c/code\u003e or \u003ccode\u003eG\u003c/code\u003e (Generate data, client-side or server-side)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGenerate data and load it into the standard tables, replacing any data already present.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode\u003eg\u003c/code\u003e (client-side data generation), data is generated in \u003ccode\u003epgbench\u003c/code\u003e client and then sent to the server. This uses the client/server bandwidth extensively through a \u003ccode\u003eCOPY\u003c/code\u003e. \u003ccode\u003epgbench\u003c/code\u003e uses the \u003ccode\u003eFREEZE\u003c/code\u003e option to load data into ordinary (non-partition) tables with version 14 or later of \u003cspan\u003ePostgreSQL\u003c/span\u003e to speed up subsequent \u003ccode\u003eVACUUM\u003c/code\u003e. Using \u003ccode\u003eg\u003c/code\u003e causes logging to print one message every 100,000 rows while generating data for all tables.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode\u003eG\u003c/code\u003e (server-side data generation), only small queries are sent from the \u003ccode\u003epgbench\u003c/code\u003e client and then data is actually generated in the server. No significant bandwidth is required for this variant, but the server will do more work. Using \u003ccode\u003eG\u003c/code\u003e causes logging not to print any progress message while generating data.\u003c/p\u003e\n\u003cp\u003eThe default initialization behavior uses client-side data generation (equivalent to \u003ccode\u003eg\u003c/code\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-V\"\u003e\u003cspan\u003e\u003ccode\u003ev\u003c/code\u003e (Vacuum)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eInvoke \u003ccode\u003eVACUUM\u003c/code\u003e on the standard tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-P\"\u003e\u003cspan\u003e\u003ccode\u003ep\u003c/code\u003e (create Primary keys)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate primary key indexes on the standard tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-F\"\u003e\u003cspan\u003e\u003ccode\u003ef\u003c/code\u003e (create Foreign keys)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate foreign key constraints between the standard tables. (Note that this step is not performed by default.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FILLFACTOR\"\u003e\u003cspan\u003e\u003ccode\u003e-F\u003c/code\u003e \u003cem\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--fillfactor=\u003c/code\u003e\u003cem\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate the \u003ccode\u003epgbench_accounts\u003c/code\u003e, \u003ccode\u003epgbench_tellers\u003c/code\u003e and \u003ccode\u003epgbench_branches\u003c/code\u003e tables with the given fillfactor. Default is 100.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-NO-VACUUM-INIT\"\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform no vacuuming during initialization. (This option suppresses the \u003ccode\u003ev\u003c/code\u003e initialization step, even if it was specified in \u003ccode\u003e-I\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-QUIET\"\u003e\u003cspan\u003e\u003ccode\u003e-q\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware).\u003c/p\u003e\n\u003cp\u003eThis setting has no effect if \u003ccode\u003eG\u003c/code\u003e is specified in \u003ccode\u003e-I\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SCALE-INIT\"\u003e\u003cspan\u003e\u003ccode\u003e-s\u003c/code\u003e \u003cem\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--scale=\u003c/code\u003e\u003cem\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMultiply the number of rows generated by the scale factor. For example, \u003ccode\u003e-s 100\u003c/code\u003e will create 10,000,000 rows in the \u003ccode\u003epgbench_accounts\u003c/code\u003e table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers (\u003ccode\u003eaid\u003c/code\u003e columns) will switch to using larger integers (\u003ccode\u003ebigint\u003c/code\u003e), in order to be big enough to hold the range of account identifiers.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FOREIGN-KEYS\"\u003e\u003cspan\u003e\u003ccode\u003e--foreign-keys\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate foreign key constraints between the standard tables. (This option adds the \u003ccode\u003ef\u003c/code\u003e step to the initialization step sequence, if it is not already present.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INDEX-TABLESPACE\"\u003e\u003cspan\u003e\u003ccode\u003e--index-tablespace=\u003cem\u003e\u003ccode\u003eindex_tablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate indexes in the specified tablespace, rather than the default tablespace.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PARTITION-METHOD\"\u003e\u003cspan\u003e\u003ccode\u003e--partition-method=\u003cem\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a partitioned \u003ccode\u003epgbench_accounts\u003c/code\u003e table with \u003cem\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e method. Expected values are \u003ccode\u003erange\u003c/code\u003e or \u003ccode\u003ehash\u003c/code\u003e. This option requires that \u003ccode\u003e--partitions\u003c/code\u003e is set to non-zero. If unspecified, default is \u003ccode\u003erange\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PARTITIONS\"\u003e\u003cspan\u003e\u003ccode\u003e--partitions=\u003cem\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a partitioned \u003ccode\u003epgbench_accounts\u003c/code\u003e table with \u003cem\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e partitions of nearly equal size for the scaled number of accounts. Default is \u003ccode\u003e0\u003c/code\u003e, meaning no partitioning.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TABLESPACE\"\u003e\u003cspan\u003e\u003ccode\u003e--tablespace=\u003cem\u003e\u003ccode\u003etablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate tables in the specified tablespace, rather than the default tablespace.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-UNLOGGED-TABLES\"\u003e\u003cspan\u003e\u003ccode\u003e--unlogged-tables\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate all tables as unlogged tables, rather than permanent tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"PGBENCH-RUN-OPTIONS\"\u003e\n\u003ch3\u003eBenchmarking Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e accepts the following command-line benchmarking arguments:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"PGBENCH-OPTION-BUILTIN\"\u003e\u003cspan\u003e\u003ccode\u003e-b\u003c/code\u003e \u003cem\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--builtin\u003c/code\u003e=\u003cem\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAdd the specified built-in script to the list of scripts to be executed. Available built-in scripts are: \u003ccode\u003etpcb-like\u003c/code\u003e, \u003ccode\u003esimple-update\u003c/code\u003e and \u003ccode\u003eselect-only\u003c/code\u003e. Unambiguous prefixes of built-in names are accepted. With the special name \u003ccode\u003elist\u003c/code\u003e, show the list of built-in scripts and exit immediately.\u003c/p\u003e\n\u003cp\u003eOptionally, write an integer weight after \u003ccode\u003e@\u003c/code\u003e to adjust the probability of selecting this script versus other ones. The default weight is 1. See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-CLIENT\"\u003e\u003cspan\u003e\u003ccode\u003e-c\u003c/code\u003e \u003cem\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--client=\u003c/code\u003e\u003cem\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of clients simulated, that is, number of concurrent database sessions. Default is 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-CONNECT\"\u003e\u003cspan\u003e\u003ccode\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--connect\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEstablish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-DEFINE\"\u003e\u003cspan\u003e\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode\u003e=\u003c/code\u003e\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--define=\u003c/code\u003e\u003cem\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode\u003e=\u003c/code\u003e\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefine a variable for use by a custom script (see below). Multiple \u003ccode\u003e-D\u003c/code\u003e options are allowed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FILE\"\u003e\u003cspan\u003e\u003ccode\u003e-f\u003c/code\u003e \u003cem\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--file=\u003c/code\u003e\u003cem\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAdd a transaction script read from \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e to the list of scripts to be executed.\u003c/p\u003e\n\u003cp\u003eOptionally, write an integer weight after \u003ccode\u003e@\u003c/code\u003e to adjust the probability of selecting this script versus other ones. The default weight is 1. (To use a script file name that includes an \u003ccode\u003e@\u003c/code\u003e character, append a weight so that there is no ambiguity, for example \u003ccode\u003efilen@me@1\u003c/code\u003e.) See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-JOBS\"\u003e\u003cspan\u003e\u003ccode\u003e-j\u003c/code\u003e \u003cem\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--jobs=\u003c/code\u003e\u003cem\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of worker threads within \u003cspan\u003epgbench\u003c/span\u003e. Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LOG\"\u003e\u003cspan\u003e\u003ccode\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--log\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite information about each transaction to a log file. See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LATENCY-LIMIT\"\u003e\u003cspan\u003e\u003ccode\u003e-L\u003c/code\u003e \u003cem\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--latency-limit=\u003c/code\u003e\u003cem\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTransactions that last more than \u003cem\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e milliseconds are counted and reported separately, as \u003cem\u003elate\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eWhen throttling is used (\u003ccode\u003e--rate=...\u003c/code\u003e), transactions that lag behind schedule by more than \u003cem\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e ms, and thus have no hope of meeting the latency limit, are not sent to the server at all. They are counted and reported separately as \u003cem\u003eskipped\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode\u003e--max-tries\u003c/code\u003e option is used, a transaction which fails due to a serialization anomaly or from a deadlock will not be retried if the total time of all its tries is greater than \u003cem\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e ms. To limit only the time of tries and not their number, use \u003ccode\u003e--max-tries=0\u003c/code\u003e. By default, the option \u003ccode\u003e--max-tries\u003c/code\u003e is set to 1 and transactions with serialization/deadlock errors are not retried. See \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information about retrying such transactions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROTOCOL\"\u003e\u003cspan\u003e\u003ccode\u003e-M\u003c/code\u003e \u003cem\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--protocol=\u003c/code\u003e\u003cem\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eProtocol to use for submitting queries to the server:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003esimple\u003c/code\u003e: use simple query protocol.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eextended\u003c/code\u003e: use extended query protocol.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eprepared\u003c/code\u003e: use extended query protocol with prepared statements.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eIn the \u003ccode\u003eprepared\u003c/code\u003e mode, \u003cspan\u003epgbench\u003c/span\u003e reuses the parse analysis result starting from the second query iteration, so \u003cspan\u003epgbench\u003c/span\u003e runs faster than in other modes.\u003c/p\u003e\n\u003cp\u003eThe default is simple query protocol. (See \u003ca href=\"/docs/18/protocol.html\" rel=\"nofollow\"\u003eChapter 54\u003c/a\u003e for more information.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-NO-VACUUM-RUN\"\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform no vacuuming before running the test. This option is \u003cspan\u003e\u003cem\u003enecessary\u003c/em\u003e\u003c/span\u003e if you are running a custom test scenario that does not include the standard tables \u003ccode\u003epgbench_accounts\u003c/code\u003e, \u003ccode\u003epgbench_branches\u003c/code\u003e, \u003ccode\u003epgbench_history\u003c/code\u003e, and \u003ccode\u003epgbench_tellers\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SKIP-SOME-UPDATES\"\u003e\u003cspan\u003e\u003ccode\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--skip-some-updates\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun built-in simple-update script. Shorthand for \u003ccode\u003e-b simple-update\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROGRESS\"\u003e\u003cspan\u003e\u003ccode\u003e-P\u003c/code\u003e \u003cem\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--progress=\u003c/code\u003e\u003cem\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow progress report every \u003cem\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling (\u003ccode\u003e-R\u003c/code\u003e), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When \u003ccode\u003e--max-tries\u003c/code\u003e is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-REPORT-LATENCIES\"\u003e\u003cspan\u003e\u003ccode\u003e-r\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--report-per-command\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the \u003ccode\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-RATE\"\u003e\u003cspan\u003e\u003ccode\u003e-R\u003c/code\u003e \u003cem\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--rate=\u003c/code\u003e\u003cem\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExecute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won\u0026#39;t impact the results.\u003c/p\u003e\n\u003cp\u003eThe rate is targeted by starting transactions along a Poisson-distributed schedule time line. The expected start time schedule moves forward based on when the client first started, not when the previous transaction ended. That approach means that when transactions go past their original scheduled end time, it is possible for later ones to catch up again.\u003c/p\u003e\n\u003cp\u003eWhen throttling is active, the transaction latency reported at the end of the run is calculated from the scheduled start times, so it includes the time each transaction had to wait for the previous transaction to finish. The wait time is called the schedule lag time, and its average and maximum are also reported separately. The transaction latency with respect to the actual transaction start time, i.e., the time spent executing the transaction in the database, can be computed by subtracting the schedule lag time from the reported latency.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003e--latency-limit\u003c/code\u003e is used together with \u003ccode\u003e--rate\u003c/code\u003e, a transaction can lag behind so much that it is already over the latency limit when the previous transaction ends, because the latency is calculated from the scheduled start time. Such transactions are not sent to the server, but are skipped altogether and counted separately.\u003c/p\u003e\n\u003cp\u003eA high schedule lag time is an indication that the system cannot process transactions at the specified rate, with the chosen number of clients and threads. When the average transaction execution time is longer than the scheduled interval between each transaction, each successive transaction will fall further behind, and the schedule lag time will keep increasing the longer the test run is. When that happens, you will have to reduce the specified transaction rate.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SCALE-RUN\"\u003e\u003cspan\u003e\u003ccode\u003e-s\u003c/code\u003e \u003cem\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--scale=\u003c/code\u003e\u003cem\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport the specified scale factor in \u003cspan\u003epgbench\u003c/span\u003e\u0026#39;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 \u003ccode\u003epgbench_branches\u003c/code\u003e table. However, when testing only custom benchmarks (\u003ccode\u003e-f\u003c/code\u003e option), the scale factor will be reported as 1 unless this option is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SELECT-ONLY\"\u003e\u003cspan\u003e\u003ccode\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--select-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun built-in select-only script. Shorthand for \u003ccode\u003e-b select-only\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TRANSACTIONS\"\u003e\u003cspan\u003e\u003ccode\u003e-t\u003c/code\u003e \u003cem\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--transactions=\u003c/code\u003e\u003cem\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of transactions each client runs. Default is 10.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TIME\"\u003e\u003cspan\u003e\u003ccode\u003e-T\u003c/code\u003e \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--time=\u003c/code\u003e\u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun the test for this many seconds, rather than a fixed number of transactions per client. \u003ccode\u003e-t\u003c/code\u003e and \u003ccode\u003e-T\u003c/code\u003e are mutually exclusive.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VACUUM-ALL\"\u003e\u003cspan\u003e\u003ccode\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--vacuum-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eVacuum all four standard tables before running the test. With neither \u003ccode\u003e-n\u003c/code\u003e nor \u003ccode\u003e-v\u003c/code\u003e, \u003cspan\u003epgbench\u003c/span\u003e will vacuum the \u003ccode\u003epgbench_tellers\u003c/code\u003e and \u003ccode\u003epgbench_branches\u003c/code\u003e tables, and will truncate \u003ccode\u003epgbench_history\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-AGGREGATE-INTERVAL\"\u003e\u003cspan\u003e\u003ccode\u003e--aggregate-interval=\u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLength of aggregation interval (in seconds). May be used only with \u003ccode\u003e-l\u003c/code\u003e option. With this option, the log contains per-interval summary data, as described below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-EXIT-ON-ABORT\"\u003e\u003cspan\u003e\u003ccode\u003e--exit-on-abort\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by \u003ccode\u003e-t\u003c/code\u003e or \u003ccode\u003e-T\u003c/code\u003e option, and \u003cspan\u003epgbench\u003c/span\u003e will print an incomplete results in this case.\u003c/p\u003e\n\u003cp\u003eNote that serialization failures or deadlock failures do not abort the client, so they are not affected by this option. See \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FAILURES-DETAILED\"\u003e\u003cspan\u003e\u003ccode\u003e--failures-detailed\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eserialization failures;\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003edeadlock failures;\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eSee \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LOG-PREFIX\"\u003e\u003cspan\u003e\u003ccode\u003e--log-prefix=\u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the filename prefix for the log files created by \u003ccode\u003e--log\u003c/code\u003e. The default is \u003ccode\u003epgbench_log\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-MAX-TRIES\"\u003e\u003cspan\u003e\u003ccode\u003e--max-tries=\u003cem\u003e\u003ccode\u003enumber_of_tries\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the \u003ccode\u003e--latency-limit\u003c/code\u003e option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries (\u003ccode\u003e--max-tries=0\u003c/code\u003e) without \u003ccode\u003e--latency-limit\u003c/code\u003e or \u003ccode\u003e--time\u003c/code\u003e. The default value is 1 and transactions with serialization/deadlock errors are not retried. See \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information about retrying such transactions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROGRESS-TIMESTAMP\"\u003e\u003cspan\u003e\u003ccode\u003e--progress-timestamp\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen showing progress (option \u003ccode\u003e-P\u003c/code\u003e), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-RANDOM-SEED\"\u003e\u003cspan\u003e\u003ccode\u003e--random-seed=\u003c/code\u003e\u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e may be: \u003ccode\u003etime\u003c/code\u003e (the default, the seed is based on the current time), \u003ccode\u003erand\u003c/code\u003e (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script (\u003ccode\u003erandom...\u003c/code\u003e functions) or implicitly (for instance option \u003ccode\u003e--rate\u003c/code\u003e uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e may also be provided through the environment variable \u003ccode\u003ePGBENCH_RANDOM_SEED\u003c/code\u003e. To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable.\u003c/p\u003e\n\u003cp\u003eSetting the seed explicitly allows to reproduce a \u003ccode\u003epgbench\u003c/code\u003e run exactly, as far as random numbers are concerned. As the random state is managed per thread, this means the exact same \u003ccode\u003epgbench\u003c/code\u003e run for an identical invocation if there is one client per thread and there are no external or data dependencies. From a statistical viewpoint reproducing runs exactly is a bad idea because it can hide the performance variability or improve performance unduly, e.g., by hitting the same pages as a previous run. However, it may also be of great help for debugging, for instance re-running a tricky case which leads to an error. Use wisely.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SAMPLING-RATE\"\u003e\u003cspan\u003e\u003ccode\u003e--sampling-rate=\u003cem\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged.\u003c/p\u003e\n\u003cp\u003eRemember to take the sampling rate into account when processing the log file. For example, when computing TPS values, you need to multiply the numbers accordingly (e.g., with 0.01 sample rate, you\u0026#39;ll only get 1/100 of the actual TPS).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SHOW-SCRIPT\"\u003e\u003cspan\u003e\u003ccode\u003e--show-script=\u003c/code\u003e\u003cem\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow the actual code of builtin script \u003cem\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e on stderr, and exit immediately.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VERBOSE-ERRORS\"\u003e\u003cspan\u003e\u003ccode\u003e--verbose-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"PGBENCH-COMMON-OPTIONS\"\u003e\n\u003ch3\u003eCommon Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e also accepts the following common command-line arguments for connection parameters and other common settings:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"PGBENCH-OPTION-DEBUG\"\u003e\u003cspan\u003e\u003ccode\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint debugging output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-HOST\"\u003e\u003cspan\u003e\u003ccode\u003e-h\u003c/code\u003e \u003cem\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--host=\u003c/code\u003e\u003cem\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server\u0026#39;s host name\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PORT\"\u003e\u003cspan\u003e\u003ccode\u003e-p\u003c/code\u003e \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--port=\u003c/code\u003e\u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server\u0026#39;s port number\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-USERNAME\"\u003e\u003cspan\u003e\u003ccode\u003e-U\u003c/code\u003e \u003cem\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--username=\u003c/code\u003e\u003cem\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe user name to connect as\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VERSION\"\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan\u003epgbench\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-HELP\"\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan\u003epgbench\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003eA successful run will exit with status 0. Exit status 1 indicates static problems such as invalid command-line options or internal errors which are supposed to never occur. Early errors that occur when starting benchmark such as initial connection failures also exit with status 1. Errors during the run such as database errors or problems in the script will result in exit status 2. In the latter case, \u003cspan\u003epgbench\u003c/span\u003e will print partial results if \u003ccode\u003e--exit-on-abort\u003c/code\u003e option is not specified.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.8\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"PGBENCH-ENVIRONMENT-PGDATABASE\"\u003e\u003cspan\u003e\u003ccode\u003ePGDATABASE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan\u003elibpq\u003c/span\u003e (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cdiv id=\"TRANSACTIONS-AND-SCRIPTS\"\u003e\n\u003ch3\u003eWhat Is the \u003cspan\u003e“\u003cspan\u003eTransaction\u003c/span\u003e”\u003c/span\u003e Actually Performed in \u003cspan\u003epgbench\u003c/span\u003e?\u003c/h3\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e executes test scripts chosen randomly from a specified list. The scripts may include built-in scripts specified with \u003ccode\u003e-b\u003c/code\u003e and user-provided scripts specified with \u003ccode\u003e-f\u003c/code\u003e. Each script may be given a relative weight specified after an \u003ccode\u003e@\u003c/code\u003e so as to change its selection probability. The default weight is \u003ccode\u003e1\u003c/code\u003e. Scripts with a weight of \u003ccode\u003e0\u003c/code\u003e are ignored.\u003c/p\u003e\n\u003cp\u003eThe default built-in transaction script (also invoked with \u003ccode\u003e-b tpcb-like\u003c/code\u003e) issues seven commands per transaction over randomly chosen \u003ccode\u003eaid\u003c/code\u003e, \u003ccode\u003etid\u003c/code\u003e, \u003ccode\u003ebid\u003c/code\u003e and \u003ccode\u003edelta\u003c/code\u003e. The scenario is inspired by the TPC-B benchmark, but is not actually TPC-B, hence the name.\u003c/p\u003e\n\u003cdiv\u003e\n\u003col\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eBEGIN;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eUPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eSELECT abalance FROM pgbench_accounts WHERE aid = :aid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eUPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eUPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eINSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eEND;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n\u003cp\u003eIf you select the \u003ccode\u003esimple-update\u003c/code\u003e built-in (also \u003ccode\u003e-N\u003c/code\u003e), steps 4 and 5 aren\u0026#39;t included in the transaction. This will avoid update contention on these tables, but it makes the test case even less like TPC-B.\u003c/p\u003e\n\u003cp\u003eIf you select the \u003ccode\u003eselect-only\u003c/code\u003e built-in (also \u003ccode\u003e-S\u003c/code\u003e), only the \u003ccode\u003eSELECT\u003c/code\u003e is issued.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.3\"\u003e\n\u003ch3\u003eCustom Scripts\u003c/h3\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e has support for running custom benchmark scenarios by replacing the default transaction script (described above) with a transaction script read from a file (\u003ccode\u003e-f\u003c/code\u003e option). In this case a \u003cspan\u003e“\u003cspan\u003etransaction\u003c/span\u003e”\u003c/span\u003e counts as one execution of a script file.\u003c/p\u003e\n\u003cp\u003eA script file contains one or more SQL commands terminated by semicolons. Empty lines and lines beginning with \u003ccode\u003e--\u003c/code\u003e are ignored. Script files can also contain \u003cspan\u003e“\u003cspan\u003emeta commands\u003c/span\u003e”\u003c/span\u003e, which are interpreted by \u003cspan\u003epgbench\u003c/span\u003e itself, as described below.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eBefore \u003cspan\u003ePostgreSQL\u003c/span\u003e 9.6, SQL commands in script files were terminated by newlines, and so they could not be continued across lines. Now a semicolon is \u003cspan\u003e\u003cem\u003erequired\u003c/em\u003e\u003c/span\u003e to separate consecutive SQL commands (though an SQL command does not need one if it is followed by a meta command). If you need to create a script file that works with both old and new versions of \u003cspan\u003epgbench\u003c/span\u003e, be sure to write each SQL command on a single line ending with a semicolon.\u003c/p\u003e\n\u003cp\u003eIt is assumed that \u003cspan\u003epgbench\u003c/span\u003e scripts do not contain incomplete blocks of SQL transactions. If at runtime the client reaches the end of the script without completing the last transaction block, it will be aborted.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThere is a simple variable-substitution facility for script files. Variable names must consist of letters (including non-Latin letters), digits, and underscores, with the first character not being a digit. Variables can be set by the command-line \u003ccode\u003e-D\u003c/code\u003e option, explained above, or by the meta commands explained below. In addition to any variables preset by \u003ccode\u003e-D\u003c/code\u003e command-line options, there are a few variables that are preset automatically, listed in \u003ca href=\"/docs/18/pgbench.html#PGBENCH-AUTOMATIC-VARIABLES\" rel=\"nofollow\"\u003eTable 301\u003c/a\u003e. A value specified for these variables using \u003ccode\u003e-D\u003c/code\u003e takes precedence over the automatic presets. Once set, a variable\u0026#39;s value can be inserted into an SQL command by writing \u003ccode\u003e:\u003c/code\u003e\u003cem\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e. When running more than one client session, each session has its own set of variables. \u003cspan\u003epgbench\u003c/span\u003e supports up to 255 variable uses in one statement.\u003c/p\u003e\n\u003cdiv id=\"PGBENCH-AUTOMATIC-VARIABLES\"\u003e\n\u003cp\u003e\u003cstrong\u003eTable 301. pgbench Automatic Variables\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv\u003e\n\u003ctable\u003e\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eVariable\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003eclient_id\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eunique number identifying the client session (starts from zero)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003edefault_seed\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eseed used in hash and pseudorandom permutation functions by default\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003erandom_seed\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003erandom generator seed (unless overwritten with \u003ccode\u003e-D\u003c/code\u003e)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode\u003escale\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003ecurrent scale factor\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003cp\u003eScript file meta commands begin with a backslash (\u003ccode\u003e\\\u003c/code\u003e) and normally extend to the end of the line, although they can be continued to additional lines by writing backslash-return. Arguments to a meta command are separated by white space. These meta commands are supported:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-GSET\"\u003e\u003cspan\u003e\u003ccode\u003e\\gset [\u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e \u003ccode\u003e\\aset [\u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese commands may be used to end SQL queries, taking the place of the terminating semicolon (\u003ccode\u003e;\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode\u003e\\gset\u003c/code\u003e command is used, the preceding SQL query is expected to return one row, the columns of which are stored into variables named after column names, and prefixed with \u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e if provided.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode\u003e\\aset\u003c/code\u003e command is used, all combined SQL queries (separated by \u003ccode\u003e\\;\u003c/code\u003e) have their columns stored into variables named after column names, and prefixed with \u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e if provided. If a query returns no row, no assignment is made and the variable can be tested for existence to detect this. If a query returns more than one row, the last value is kept.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\gset\u003c/code\u003e and \u003ccode\u003e\\aset\u003c/code\u003e cannot be used in pipeline mode, since the query results are not yet available by the time the commands would need them.\u003c/p\u003e\n\u003cp\u003eThe following example puts the final account balance from the first query into variable \u003cem\u003e\u003ccode\u003eabalance\u003c/code\u003e\u003c/em\u003e, and fills variables \u003cem\u003e\u003ccode\u003ep_two\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003ep_three\u003c/code\u003e\u003c/em\u003e with integers from the third query. The result of the second query is discarded. The result of the two last combined queries are stored in variables \u003cem\u003e\u003ccode\u003efour\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003efive\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cpre\u003eUPDATE pgbench_accounts\n  SET abalance = abalance + :delta\n  WHERE aid = :aid\n  RETURNING abalance \\gset\n-- compound of two queries\nSELECT 1 \\;\nSELECT 2 AS two, 3 AS three \\gset p_\nSELECT 4 AS four \\; SELECT 5 AS five \\aset\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-IF-ELSE\"\u003e\u003cspan\u003e\u003ccode\u003e\\if\u003c/code\u003e \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\elif\u003c/code\u003e \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\else\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\endif\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements nestable conditional blocks, similarly to \u003ccode\u003epsql\u003c/code\u003e\u0026#39;s \u003ca href=\"/docs/18/app-psql.html#PSQL-METACOMMAND-IF\" rel=\"nofollow\"\u003e\u003ccode\u003e\\if\u003c/code\u003e \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e. Conditional expressions are identical to those with \u003ccode\u003e\\set\u003c/code\u003e, with non-zero values interpreted as true.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SET\"\u003e\u003cspan\u003e\u003ccode\u003e\\set \u003cem\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets variable \u003cem\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e to a value calculated from \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e. The expression may contain the \u003ccode\u003eNULL\u003c/code\u003e constant, Boolean constants \u003ccode\u003eTRUE\u003c/code\u003e and \u003ccode\u003eFALSE\u003c/code\u003e, integer constants such as \u003ccode\u003e5432\u003c/code\u003e, double constants such as \u003ccode\u003e3.14159\u003c/code\u003e, references to variables \u003ccode\u003e:\u003c/code\u003e\u003cem\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e, \u003ca href=\"/docs/18/pgbench.html#PGBENCH-BUILTIN-OPERATORS\" title=\"Built-in Operators\" rel=\"nofollow\"\u003eoperators\u003c/a\u003e with their usual SQL precedence and associativity, \u003ca href=\"/docs/18/pgbench.html#PGBENCH-BUILTIN-FUNCTIONS\" title=\"Built-In Functions\" rel=\"nofollow\"\u003efunction calls\u003c/a\u003e, SQL \u003ca href=\"/docs/18/functions-conditional.html#FUNCTIONS-CASE\" rel=\"nofollow\"\u003e\u003ccode\u003eCASE\u003c/code\u003e generic conditional expressions\u003c/a\u003e and parentheses.\u003c/p\u003e\n\u003cp\u003eFunctions and most operators return \u003ccode\u003eNULL\u003c/code\u003e on \u003ccode\u003eNULL\u003c/code\u003e input.\u003c/p\u003e\n\u003cp\u003eFor conditional purposes, non zero numerical values are \u003ccode\u003eTRUE\u003c/code\u003e, zero numerical values and \u003ccode\u003eNULL\u003c/code\u003e are \u003ccode\u003eFALSE\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eToo large or small integer and double constants, as well as integer arithmetic operators (\u003ccode\u003e+\u003c/code\u003e, \u003ccode\u003e-\u003c/code\u003e, \u003ccode\u003e*\u003c/code\u003e and \u003ccode\u003e/\u003c/code\u003e) raise errors on overflows.\u003c/p\u003e\n\u003cp\u003eWhen no final \u003ccode\u003eELSE\u003c/code\u003e clause is provided to a \u003ccode\u003eCASE\u003c/code\u003e, the default value is \u003ccode\u003eNULL\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre\u003e\\set ntellers 10 * :scale\n\\set aid (1021 * random(1, 100000 * :scale)) % \\\n           (100000 * :scale) + 1\n\\set divx CASE WHEN :x \u0026lt;\u0026gt; 0 THEN :y/:x ELSE NULL END\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SLEEP\"\u003e\u003cspan\u003e\u003ccode\u003e\\sleep \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [ us | ms | s ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCauses script execution to sleep for the specified duration in microseconds (\u003ccode\u003eus\u003c/code\u003e), milliseconds (\u003ccode\u003ems\u003c/code\u003e) or seconds (\u003ccode\u003es\u003c/code\u003e). If the unit is omitted then seconds are the default. \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e can be either an integer constant or a \u003ccode\u003e:\u003c/code\u003e\u003cem\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e reference to a variable having an integer value.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003e\\sleep 10 ms\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SETSHELL\"\u003e\u003cspan\u003e\u003ccode\u003e\\setshell \u003cem\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets variable \u003cem\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e to the result of the shell command \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e with the given \u003cem\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e(s). The command must return an integer value through its standard output.\u003c/p\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e and each \u003cem\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e can be either a text constant or a \u003ccode\u003e:\u003c/code\u003e\u003cem\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e reference to a variable. If you want to use an \u003cem\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e starting with a colon, write an additional colon at the beginning of \u003cem\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003e\\setshell variable_to_be_assigned command literal_argument :variable ::literal_starting_with_colon\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SHELL\"\u003e\u003cspan\u003e\u003ccode\u003e\\shell \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSame as \u003ccode\u003e\\setshell\u003c/code\u003e, but the result of the command is discarded.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003e\\shell command literal_argument :variable ::literal_starting_with_colon\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-PIPELINE\"\u003e\u003cspan\u003e\u003ccode\u003e\\startpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\syncpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\endpipeline\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements pipelining of SQL statements. A pipeline must begin with a \u003ccode\u003e\\startpipeline\u003c/code\u003e and end with an \u003ccode\u003e\\endpipeline\u003c/code\u003e. In between there may be any number of \u003ccode\u003e\\syncpipeline\u003c/code\u003e commands, which sends a \u003ca href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY\" rel=\"nofollow\"\u003esync message\u003c/a\u003e without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See \u003ca href=\"/docs/18/libpq-pipeline-mode.html\" rel=\"nofollow\"\u003eSection 32.5\u003c/a\u003e for more details. Pipeline mode requires the use of extended query protocol.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"PGBENCH-BUILTIN-OPERATORS\"\u003e\n\u003ch3\u003eBuilt-in Operators\u003c/h3\u003e\n\u003cp\u003eThe arithmetic, bitwise, comparison and logical operators listed in \u003ca href=\"/docs/18/pgbench.html#PGBENCH-OPERATORS\" rel=\"nofollow\"\u003eTable 302\u003c/a\u003e are built into \u003cspan\u003epgbench\u003c/span\u003e and may be used in expressions appearing in \u003ca href=\"/docs/18/pgbench.html#PGBENCH-METACOMMAND-SET\" rel=\"nofollow\"\u003e\u003ccode\u003e\\set\u003c/code\u003e\u003c/a\u003e. The operators are listed in increasing precedence order. Except as noted, operators taking two numeric inputs will produce a double value if either input is double, otherwise they produce an integer result.\u003c/p\u003e\n\u003cdiv id=\"PGBENCH-OPERATORS\"\u003e\n\u003cp\u003e\u003cstrong\u003eTable 302. pgbench Operators\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv\u003e\n\u003ctable\u003e\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003e\n\u003cp\u003eOperator\u003c/p\u003e\n\u003cp\u003eDescription\u003c/p\u003e\n\u003cp\u003eExample(s)\u003c/p\u003e\n\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode\u003eOR\u003c/code\u003e \u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical OR\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 or 0\u003c/code\u003e → \u003ccode\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode\u003eAND\u003c/code\u003e \u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical AND\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e3 and 0\u003c/code\u003e → \u003ccode\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003eNOT\u003c/code\u003e \u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical NOT\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003enot false\u003c/code\u003e → \u003ccode\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode\u003eIS [NOT] (NULL|TRUE|FALSE)\u003c/code\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBoolean value tests\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e1 is null\u003c/code\u003e → \u003ccode\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e \u003ccode\u003eISNULL|NOTNULL\u003c/code\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNullness tests\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e1 notnull\u003c/code\u003e → \u003ccode\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e=\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eEqual\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 = 4\u003c/code\u003e → \u003ccode\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026lt;\u0026gt;\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNot equal\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 \u0026lt;\u0026gt; 4\u003c/code\u003e → \u003ccode\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e!=\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNot equal\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 != 5\u003c/code\u003e → \u003ccode\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026lt;\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLess than\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 \u0026lt; 4\u003c/code\u003e → \u003ccode\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026lt;=\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLess than or equal to\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 \u0026lt;= 4\u003c/code\u003e → \u003ccode\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026gt;\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eGreater than\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 \u0026gt; 4\u003c/code\u003e → \u003ccode\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026gt;=\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eGreater than or equal to\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 \u0026gt;= 4\u003c/code\u003e → \u003ccode\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e|\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise OR\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e1 | 2\u003c/code\u003e → \u003ccode\u003e3\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e#\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise XOR\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e1 # 3\u003c/code\u003e → \u003ccode\u003e2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026amp;\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise AND\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e1 \u0026amp; 3\u003c/code\u003e → \u003ccode\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003e~\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise NOT\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e~ 1\u003c/code\u003e → \u003ccode\u003e-2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026lt;\u0026lt;\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise shift left\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e1 \u0026lt;\u0026lt; 2\u003c/code\u003e → \u003ccode\u003e4\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e\u0026gt;\u0026gt;\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise shift right\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e8 \u0026gt;\u0026gt; 2\u003c/code\u003e → \u003ccode\u003e2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e+\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eAddition\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 + 4\u003c/code\u003e → \u003ccode\u003e9\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e-\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSubtraction\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e3 - 2.0\u003c/code\u003e → \u003ccode\u003e1.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e*\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eMultiplication\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 * 4\u003c/code\u003e → \u003ccode\u003e20\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e/\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eDivision (truncates the result towards zero if both inputs are integers)\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e5 / 3\u003c/code\u003e → \u003ccode\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode\u003e%\u003c/code\u003e \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eModulo (remainder)\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e3 % 2\u003c/code\u003e → \u003ccode\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003e-\u003c/code\u003e \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode\u003e\u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNegation\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e- 2.0\u003c/code\u003e → \u003ccode\u003e-2.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003c/div\u003e\n\u003cdiv id=\"PGBENCH-BUILTIN-FUNCTIONS\"\u003e\n\u003ch3\u003eBuilt-In Functions\u003c/h3\u003e\n\u003cp\u003eThe functions listed in \u003ca href=\"/docs/18/pgbench.html#PGBENCH-FUNCTIONS\" rel=\"nofollow\"\u003eTable 303\u003c/a\u003e are built into \u003cspan\u003epgbench\u003c/span\u003e and may be used in expressions appearing in \u003ca href=\"/docs/18/pgbench.html#PGBENCH-METACOMMAND-SET\" rel=\"nofollow\"\u003e\u003ccode\u003e\\set\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv id=\"PGBENCH-FUNCTIONS\"\u003e\n\u003cp\u003e\u003cstrong\u003eTable 303. pgbench Functions\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv\u003e\n\u003ctable\u003e\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003e\n\u003cp\u003eFunction\u003c/p\u003e\n\u003cp\u003eDescription\u003c/p\u003e\n\u003cp\u003eExample(s)\u003c/p\u003e\n\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003eabs\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → same type as input\u003c/p\u003e\n\u003cp\u003eAbsolute value\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eabs(-17)\u003c/code\u003e → \u003ccode\u003e17\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003edebug\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → same type as input\u003c/p\u003e\n\u003cp\u003ePrints the argument to \u003cspan\u003estderr\u003c/span\u003e, and returns the argument.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003edebug(5432.1)\u003c/code\u003e → \u003ccode\u003e5432.1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003edouble\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eCasts to double.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003edouble(5432)\u003c/code\u003e → \u003ccode\u003e5432.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003eexp\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eExponential (\u003ccode\u003ee\u003c/code\u003e raised to the given power)\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eexp(1.0)\u003c/code\u003e → \u003ccode\u003e2.718281828459045\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003egreatest\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [\u003cspan\u003e, \u003ccode\u003e...\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode\u003edouble\u003c/code\u003e if any argument is double, else \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSelects the largest value among the arguments.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003egreatest(5, 4, 3, 2)\u003c/code\u003e → \u003ccode\u003e5\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003ehash\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan\u003e, \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eThis is an alias for \u003ccode\u003ehash_murmur2\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ehash(10, 5432)\u003c/code\u003e → \u003ccode\u003e-5817877081768721676\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003ehash_fnv1a\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan\u003e, \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes \u003ca href=\"https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function\" rel=\"nofollow\"\u003eFNV-1a hash\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ehash_fnv1a(10, 5432)\u003c/code\u003e → \u003ccode\u003e-7793829335365542153\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003ehash_murmur2\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan\u003e, \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes \u003ca href=\"https://en.wikipedia.org/wiki/MurmurHash\" rel=\"nofollow\"\u003eMurmurHash2 hash\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ehash_murmur2(10, 5432)\u003c/code\u003e → \u003ccode\u003e-5817877081768721676\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003eint\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eCasts to integer.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eint(5.4 + 3.8)\u003c/code\u003e → \u003ccode\u003e9\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003eleast\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [\u003cspan\u003e, \u003ccode\u003e...\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode\u003edouble\u003c/code\u003e if any argument is double, else \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSelects the smallest value among the arguments.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eleast(5, 4, 3, 2.1)\u003c/code\u003e → \u003ccode\u003e2.1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003eln\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNatural logarithm\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eln(2.718281828459045)\u003c/code\u003e → \u003ccode\u003e1.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003emod\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eModulo (remainder)\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003emod(54, 32)\u003c/code\u003e → \u003ccode\u003e22\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003epermute\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e [, \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e ] ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003ePermuted value of \u003cem\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e, in the range \u003ccode\u003e[0, size)\u003c/code\u003e. This is the new position of \u003cem\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e (modulo \u003cem\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e) in a pseudorandom permutation of the integers \u003ccode\u003e0...size-1\u003c/code\u003e, parameterized by \u003cem\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epermute(0, 4)\u003c/code\u003e → \u003ccode\u003ean integer between 0 and 3\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003epi\u003c/code\u003e () → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eApproximate value of \u003cspan\u003eπ\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epi()\u003c/code\u003e → \u003ccode\u003e3.14159265358979323846\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003epow\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epower\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e raised to the power of \u003cem\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epow(2.0, 10)\u003c/code\u003e → \u003ccode\u003e1024.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003erandom\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a uniformly-distributed random integer in \u003ccode\u003e[lb, ub]\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003erandom(1, 10)\u003c/code\u003e → \u003ccode\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003erandom_exponential\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes an exponentially-distributed random integer in \u003ccode\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003erandom_exponential(1, 10, 3.0)\u003c/code\u003e → \u003ccode\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003erandom_gaussian\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a Gaussian-distributed random integer in \u003ccode\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003erandom_gaussian(1, 10, 2.5)\u003c/code\u003e → \u003ccode\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003erandom_zipfian\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a Zipfian-distributed random integer in \u003ccode\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003erandom_zipfian(1, 10, 1.5)\u003c/code\u003e → \u003ccode\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ccode\u003esqrt\u003c/code\u003e ( \u003cem\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSquare root\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003esqrt(2.0)\u003c/code\u003e → \u003ccode\u003e1.414213562\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr\u003e\n\u003cp\u003eThe \u003ccode\u003erandom\u003c/code\u003e function generates values using a uniform distribution, that is all the values are drawn within the specified range with equal probability. The \u003ccode\u003erandom_exponential\u003c/code\u003e, \u003ccode\u003erandom_gaussian\u003c/code\u003e and \u003ccode\u003erandom_zipfian\u003c/code\u003e functions require an additional double parameter which determines the precise shape of the distribution.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eFor an exponential distribution, \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e controls the distribution by truncating a quickly-decreasing exponential distribution at \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, and then projecting onto integers between the bounds. To be precise, with\u003c/p\u003e\n\u003cdiv\u003e\n\u003cp\u003e\u003cbr\u003e\n              f(x) = exp(-parameter * (x - min) / (max - min + 1)) / (1 - exp(-parameter))\u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThen value \u003cem\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e between \u003cem\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e inclusive is drawn with probability: \u003ccode\u003ef(i) - f(i + 1)\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIntuitively, the larger the \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values close to \u003cem\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e are accessed, and the less frequently values close to \u003cem\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e are accessed. The closer to 0 \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e is, the flatter (more uniform) the access distribution. A crude approximation of the distribution is that the most frequent 1% values in the range, close to \u003cem\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e, are drawn \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e% of the time. The \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value must be strictly positive.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eFor a Gaussian distribution, the interval is mapped onto a standard normal distribution (the classical bell-shaped Gaussian curve) truncated at \u003ccode\u003e-parameter\u003c/code\u003e on the left and \u003ccode\u003e+parameter\u003c/code\u003e on the right. Values in the middle of the interval are more likely to be drawn. To be precise, if \u003ccode\u003ePHI(x)\u003c/code\u003e is the cumulative distribution function of the standard normal distribution, with mean \u003ccode\u003emu\u003c/code\u003e defined as \u003ccode\u003e(max + min) / 2.0\u003c/code\u003e, with\u003c/p\u003e\n\u003cdiv\u003e\n\u003cp\u003e\u003cbr\u003e\n              f(x) = PHI(2.0 * parameter * (x - mu) / (max - min + 1)) /\u003cbr\u003e\n                     (2.0 * PHI(parameter) - 1)\u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003ethen value \u003cem\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e between \u003cem\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e inclusive is drawn with probability: \u003ccode\u003ef(i + 0.5) - f(i - 0.5)\u003c/code\u003e. Intuitively, the larger the \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values close to the middle of the interval are drawn, and the less frequently values close to the \u003cem\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e bounds. About 67% of values are drawn from the middle \u003ccode\u003e1.0 / parameter\u003c/code\u003e, that is a relative \u003ccode\u003e0.5 / parameter\u003c/code\u003e around the mean, and 95% in the middle \u003ccode\u003e2.0 / parameter\u003c/code\u003e, that is a relative \u003ccode\u003e1.0 / parameter\u003c/code\u003e around the mean; for instance, if \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e is 4.0, 67% of values are drawn from the middle quarter (1.0 / 4.0) of the interval (i.e., from \u003ccode\u003e3.0 / 8.0\u003c/code\u003e to \u003ccode\u003e5.0 / 8.0\u003c/code\u003e) and 95% from the middle half (\u003ccode\u003e2.0 / 4.0\u003c/code\u003e) of the interval (second and third quartiles). The minimum allowed \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value is 2.0.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003erandom_zipfian\u003c/code\u003e generates a bounded Zipfian distribution. \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e defines how skewed the distribution is. The larger the \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values closer to the beginning of the interval are drawn. The distribution is such that, assuming the range starts from 1, the ratio of the probability of drawing \u003cem\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e versus drawing \u003cem\u003e\u003ccode\u003ek+1\u003c/code\u003e\u003c/em\u003e is \u003ccode\u003e((\u003cem\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e+1)/\u003cem\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e)**\u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. For example, \u003ccode\u003erandom_zipfian(1, ..., 2.5)\u003c/code\u003e produces the value \u003ccode\u003e1\u003c/code\u003e about \u003ccode\u003e(2/1)**2.5 = 5.66\u003c/code\u003e times more frequently than \u003ccode\u003e2\u003c/code\u003e, which itself is produced \u003ccode\u003e(3/2)**2.5 = 2.76\u003c/code\u003e times more frequently than \u003ccode\u003e3\u003c/code\u003e, and so on.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epgbench\u003c/span\u003e\u0026#39;s implementation is based on \u0026#34;Non-Uniform Random Variate Generation\u0026#34;, Luc Devroye, p. 550-551, Springer 1986. Due to limitations of that algorithm, the \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value is restricted to the range [1.001, 1000].\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhen designing a benchmark which selects rows non-uniformly, be aware that the rows chosen may be correlated with other data such as IDs from a sequence or the physical row ordering, which may skew performance measurements.\u003c/p\u003e\n\u003cp\u003eTo avoid this, you may wish to use the \u003ccode\u003epermute\u003c/code\u003e function, or some other additional step with similar effect, to shuffle the selected rows and remove such correlations.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eHash functions \u003ccode\u003ehash\u003c/code\u003e, \u003ccode\u003ehash_murmur2\u003c/code\u003e and \u003ccode\u003ehash_fnv1a\u003c/code\u003e accept an input value and an optional seed parameter. In case the seed isn\u0026#39;t provided the value of \u003ccode\u003e:default_seed\u003c/code\u003e is used, which is initialized randomly unless set by the command-line \u003ccode\u003e-D\u003c/code\u003e option.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epermute\u003c/code\u003e accepts an input value, a size, and an optional seed parameter. It generates a pseudorandom permutation of integers in the range \u003ccode\u003e[0, size)\u003c/code\u003e, and returns the index of the input value in the permuted values. The permutation chosen is parameterized by the seed, which defaults to \u003ccode\u003e:default_seed\u003c/code\u003e, if not specified. Unlike the hash functions, \u003ccode\u003epermute\u003c/code\u003e ensures that there are no collisions or holes in the output values. Input values outside the interval are interpreted modulo the size. The function raises an error if the size is not positive. \u003ccode\u003epermute\u003c/code\u003e can be used to scatter the distribution of non-uniform random functions such as \u003ccode\u003erandom_zipfian\u003c/code\u003e or \u003ccode\u003erandom_exponential\u003c/code\u003e so that values drawn more often are not trivially correlated. For instance, the following \u003cspan\u003epgbench\u003c/span\u003e script simulates a possible real world workload typical for social media and blogging platforms where a few accounts generate excessive load:\u003c/p\u003e\n\u003cpre\u003e\\set size 1000000\n\\set r random_zipfian(1, :size, 1.07)\n\\set k 1 + permute(:r, :size)\n\u003c/pre\u003e\n\u003cp\u003eIn some cases several distinct distributions are needed which don\u0026#39;t correlate with each other and this is when the optional seed parameter comes in handy:\u003c/p\u003e\n\u003cpre\u003e\\set k1 1 + permute(:r, :size, :default_seed + 123)\n\\set k2 1 + permute(:r, :size, :default_seed + 321)\n\u003c/pre\u003e\n\u003cp\u003eA similar behavior can also be approximated with \u003ccode\u003ehash\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e\\set size 1000000\n\\set r random_zipfian(1, 100 * :size, 1.07)\n\\set k 1 + abs(hash(:r)) % :size\n\u003c/pre\u003e\n\u003cp\u003eHowever, since \u003ccode\u003ehash\u003c/code\u003e generates collisions, some values will not be reachable and others will be more frequent than expected from the original distribution.\u003c/p\u003e\n\u003cp\u003eAs an example, the full definition of the built-in TPC-B-like transaction is:\u003c/p\u003e\n\u003cpre\u003e\\set aid random(1, 100000 * :scale)\n\\set bid random(1, 1 * :scale)\n\\set tid random(1, 10 * :scale)\n\\set delta random(-5000, 5000)\nBEGIN;\nUPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\nSELECT abalance FROM pgbench_accounts WHERE aid = :aid;\nUPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\nUPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\nINSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\nEND;\n\u003c/pre\u003e\n\u003cp\u003eThis script allows each iteration of the transaction to reference different, randomly-chosen rows. (This example also shows why it\u0026#39;s important for each client session to have its own variables — otherwise they\u0026#39;d not be independently touching different rows.)\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.6\"\u003e\n\u003ch3\u003ePer-Transaction Logging\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode\u003e-l\u003c/code\u003e option (but without the \u003ccode\u003e--aggregate-interval\u003c/code\u003e option), \u003cspan\u003epgbench\u003c/span\u003e writes information about each transaction to a log file. The log file will be named \u003ccode\u003e\u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e.\u003cem\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e defaults to \u003ccode\u003epgbench_log\u003c/code\u003e, and \u003cem\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e is the PID of the \u003cspan\u003epgbench\u003c/span\u003e process. The prefix can be changed by using the \u003ccode\u003e--log-prefix\u003c/code\u003e option. If the \u003ccode\u003e-j\u003c/code\u003e option is 2 or higher, so that there are multiple worker threads, each will have its own log file. The first worker will use the same name for its log file as in the standard single worker case. The additional log files for the other workers will be named \u003ccode\u003e\u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e.\u003cem\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e.\u003cem\u003e\u003ccode\u003emmm\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem\u003e\u003ccode\u003emmm\u003c/code\u003e\u003c/em\u003e is a sequential number for each worker starting with 1.\u003c/p\u003e\n\u003cp\u003eEach line in a log file describes one transaction. It contains the following space-separated fields:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eclient_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eidentifies the client session that ran the transaction\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003etransaction_no\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ecounts how many transactions have been run by that session\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction\u0026#39;s elapsed time, in microseconds\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003escript_no\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eidentifies the script file that was used for the transaction (useful when multiple scripts are specified with \u003ccode\u003e-f\u003c/code\u003e or \u003ccode\u003e-b\u003c/code\u003e)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003etime_epoch\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction\u0026#39;s completion time, as a Unix-epoch time stamp\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003etime_us\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003efractional-second part of transaction\u0026#39;s completion time, in microseconds\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eschedule_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction start delay, that is the difference between the transaction\u0026#39;s scheduled start time and the time it actually started, in microseconds (present only if \u003ccode\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ecount of retries after serialization or deadlock errors during the transaction (present only if \u003ccode\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eWhen both \u003ccode\u003e--rate\u003c/code\u003e and \u003ccode\u003e--latency-limit\u003c/code\u003e are used, the \u003cem\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e for a skipped transaction will be reported as \u003ccode\u003eskipped\u003c/code\u003e. If the transaction ends with a failure, its \u003cem\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e will be reported as \u003ccode\u003efailed\u003c/code\u003e. If you use the \u003ccode\u003e--failures-detailed\u003c/code\u003e option, the \u003cem\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e of the failed transaction will be reported as \u003ccode\u003eserialization\u003c/code\u003e or \u003ccode\u003edeadlock\u003c/code\u003e depending on the type of failure (see \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information).\u003c/p\u003e\n\u003cp\u003eHere is a snippet of a log file generated in a single-client run:\u003c/p\u003e\n\u003cpre\u003e0 199 2241 0 1175850568 995598\n0 200 2465 0 1175850568 998079\n0 201 2513 0 1175850569 608\n0 202 2038 0 1175850569 2663\n\u003c/pre\u003e\n\u003cp\u003eAnother example with \u003ccode\u003e--rate=100\u003c/code\u003e and \u003ccode\u003e--latency-limit=5\u003c/code\u003e (note the additional \u003cem\u003e\u003ccode\u003eschedule_lag\u003c/code\u003e\u003c/em\u003e column):\u003c/p\u003e\n\u003cpre\u003e0 81 4621 0 1412881037 912698 3005\n0 82 6173 0 1412881037 914578 4304\n0 83 skipped 0 1412881037 914578 5217\n0 83 skipped 0 1412881037 914578 5099\n0 83 4722 0 1412881037 916203 3108\n0 84 4142 0 1412881037 918023 2333\n0 85 2465 0 1412881037 919759 740\n\u003c/pre\u003e\n\u003cp\u003eIn this example, transaction 82 was late, because its latency (6.173 ms) was over the 5 ms limit. The next two transactions were skipped, because they were already late before they were even started.\u003c/p\u003e\n\u003cp\u003eThe following example shows a snippet of a log file with failures and retries, with the maximum number of tries set to 10 (note the additional \u003cem\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e column):\u003c/p\u003e\n\u003cpre\u003e3 0 47423 0 1499414498 34501 3\n3 1 8333 0 1499414498 42848 0\n3 2 8358 0 1499414498 51219 0\n4 0 72345 0 1499414498 59433 6\n1 3 41718 0 1499414498 67879 4\n1 4 8416 0 1499414498 76311 0\n3 3 33235 0 1499414498 84469 3\n0 0 failed 0 1499414498 84905 9\n2 0 failed 0 1499414498 86248 9\n3 4 8307 0 1499414498 92788 0\n\u003c/pre\u003e\n\u003cp\u003eIf the \u003ccode\u003e--failures-detailed\u003c/code\u003e option is used, the type of failure is reported in the \u003cem\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e like this:\u003c/p\u003e\n\u003cpre\u003e3 0 47423 0 1499414498 34501 3\n3 1 8333 0 1499414498 42848 0\n3 2 8358 0 1499414498 51219 0\n4 0 72345 0 1499414498 59433 6\n1 3 41718 0 1499414498 67879 4\n1 4 8416 0 1499414498 76311 0\n3 3 33235 0 1499414498 84469 3\n0 0 serialization 0 1499414498 84905 9\n2 0 serialization 0 1499414498 86248 9\n3 4 8307 0 1499414498 92788 0\n\u003c/pre\u003e\n\u003cp\u003eWhen running a long test on hardware that can handle a lot of transactions, the log files can become very large. The \u003ccode\u003e--sampling-rate\u003c/code\u003e option can be used to log only a random sample of transactions.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.7\"\u003e\n\u003ch3\u003eAggregated Logging\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode\u003e--aggregate-interval\u003c/code\u003e option, a different format is used for the log files. Each log line describes one aggregation interval. It contains the following space-separated fields:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003einterval_start\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003estart time of the interval, as a Unix-epoch time stamp\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003enum_transactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions within the interval\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esum_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of transaction latencies\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esum_latency_2\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of squares of transaction latencies\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003emin_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eminimum transaction latency\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003emax_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003emaximum transaction latency\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esum_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of transaction start delays (zero unless \u003ccode\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003esum_lag_2\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of squares of transaction start delays (zero unless \u003ccode\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003emin_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eminimum transaction start delay (zero unless \u003ccode\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003emax_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003emaximum transaction start delay (zero unless \u003ccode\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eskipped\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions skipped because they would have started too late (zero unless \u003ccode\u003e--rate\u003c/code\u003e and \u003ccode\u003e--latency-limit\u003c/code\u003e are specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eretried\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of retried transactions (zero unless \u003ccode\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of retries after serialization or deadlock errors (zero unless \u003ccode\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003eserialization_failures\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions that got a serialization error and were not retried afterwards (zero unless \u003ccode\u003e--failures-detailed\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003edeadlock_failures\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions that got a deadlock error and were not retried afterwards (zero unless \u003ccode\u003e--failures-detailed\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eHere is some example output generated with this option:\u003c/p\u003e\n\u003cpre\u003e\u003cstrong\u003e\u003ccode\u003epgbench --aggregate-interval=10 --time=20 --client=10 --log --rate=1000 --latency-limit=10 --failures-detailed --max-tries=10 test\u003c/code\u003e\u003c/strong\u003e\n\n1650260552 5178 26171317 177284491527 1136 44462 2647617 7321113867 0 9866 64 7564 28340 4148 0\n1650260562 4808 25573984 220121792172 1171 62083 3037380 9666800914 0 9998 598 7392 26621 4527 0\n\u003c/pre\u003e\n\u003cp\u003eNotice that while the plain (unaggregated) log format shows which script was used for each transaction, the aggregated format does not. Therefore if you need per-script data, you need to aggregate the data on your own.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.8\"\u003e\n\u003ch3\u003ePer-Statement Report\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode\u003e-r\u003c/code\u003e option, \u003cspan\u003epgbench\u003c/span\u003e collects the following statistics for each statement:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003elatency\u003c/code\u003e — elapsed transaction time for each statement. \u003cspan\u003epgbench\u003c/span\u003e reports an average value of all successful runs of the statement.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eThe number of failures in this statement. See \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eThe number of retries after a serialization or a deadlock error in this statement. See \u003ca href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\" rel=\"nofollow\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eThe report displays retry statistics only if the \u003ccode\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003cp\u003eAll values are computed for each statement executed by every client and are reported after the benchmark has finished.\u003c/p\u003e\n\u003cp\u003eFor the default script, the output will look similar to this:\u003c/p\u003e\n\u003cpre\u003estarting vacuum...end.\ntransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 1\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nnumber of transactions above the 50.0 ms latency limit: 1311/10000 (13.110 %)\nlatency average = 28.488 ms\nlatency stddev = 21.009 ms\ninitial connection time = 69.068 ms\ntps = 346.224794 (without initial connection time)\nstatement latencies in milliseconds and failures:\n   0.012  0  \\set aid random(1, 100000 * :scale)\n   0.002  0  \\set bid random(1, 1 * :scale)\n   0.002  0  \\set tid random(1, 10 * :scale)\n   0.002  0  \\set delta random(-5000, 5000)\n   0.319  0  BEGIN;\n   0.834  0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n   0.641  0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n  11.126  0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n  12.961  0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n   0.634  0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n   1.957  0  END;\n\u003c/pre\u003e\n\u003cp\u003eAnother example of output for the default script using serializable default transaction isolation level (\u003ccode\u003ePGOPTIONS=\u0026#39;-c default_transaction_isolation=serializable\u0026#39; pgbench ...\u003c/code\u003e):\u003c/p\u003e\n\u003cpre\u003estarting vacuum...end.\ntransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 1\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 10\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 6317/10000\nnumber of failed transactions: 3683 (36.830%)\nnumber of transactions retried: 7667 (76.670%)\ntotal number of retries: 45339\nnumber of transactions above the 50.0 ms latency limit: 106/6317 (1.678 %)\nlatency average = 17.016 ms\nlatency stddev = 13.283 ms\ninitial connection time = 45.017 ms\ntps = 186.792667 (without initial connection time)\nstatement latencies in milliseconds, failures and retries:\n  0.006     0      0  \\set aid random(1, 100000 * :scale)\n  0.001     0      0  \\set bid random(1, 1 * :scale)\n  0.001     0      0  \\set tid random(1, 10 * :scale)\n  0.001     0      0  \\set delta random(-5000, 5000)\n  0.385     0      0  BEGIN;\n  0.773     0      1  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n  0.624     0      0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n  1.098   320   3762  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n  0.582  3363  41576  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n  0.465     0      0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n  1.933     0      0  END;\n\u003c/pre\u003e\n\u003cp\u003eIf multiple script files are specified, all statistics are reported separately for each script file.\u003c/p\u003e\n\u003cp\u003eNote that collecting the additional timing information needed for per-statement latency computation adds some overhead. This will slow average execution speed and lower the computed TPS. The amount of slowdown varies significantly depending on platform and hardware. Comparing average TPS values with and without latency reporting enabled is a good way to measure if the timing overhead is significant.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"FAILURES-AND-RETRIES\"\u003e\n\u003ch3\u003eFailures and Serialization/Deadlock Retries\u003c/h3\u003e\n\u003cp\u003eWhen executing \u003cspan\u003epgbench\u003c/span\u003e, there are three main types of errors:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eErrors of the main program. They are the most serious and always result in an immediate exit from \u003cspan\u003epgbench\u003c/span\u003e with the corresponding error message. They include:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eerrors at the beginning of \u003cspan\u003epgbench\u003c/span\u003e (e.g. an invalid option value);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eerrors in the initialization mode (e.g. the query to create tables for built-in scripts fails);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eerrors before starting threads (e.g. could not connect to the database server, syntax error in the meta command, thread creation failure);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003einternal \u003cspan\u003epgbench\u003c/span\u003e errors (which are supposed to never occur...).\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eErrors when the thread manages its clients (e.g. the client could not start a connection to the database server / the socket for connecting the client to the database server has become invalid). In such cases all clients of this thread stop while other threads continue to work. However, \u003ccode\u003e--exit-on-abort\u003c/code\u003e is specified, all of the threads stop immediately in this case.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eDirect client errors. They lead to immediate exit from \u003cspan\u003epgbench\u003c/span\u003e with the corresponding error message in the case of an internal \u003cspan\u003epgbench\u003c/span\u003e error (which are supposed to never occur...) or when \u003ccode\u003e--exit-on-abort\u003c/code\u003e is specified. Otherwise in the worst case they only lead to the abortion of the failed client while other clients continue their run (but some client errors are handled without an abortion of the client and reported separately, see below). Later in this section it is assumed that the discussed errors are only the direct client errors and they are not internal \u003cspan\u003epgbench\u003c/span\u003e errors.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eA client\u0026#39;s run is aborted in case of a serious error; for example, the connection with the database server was lost or the end of script was reached without completing the last transaction. In addition, if execution of an SQL or meta command fails for reasons other than serialization or deadlock errors, the client is aborted. Otherwise, if an SQL command fails with serialization or deadlock errors, the client is not aborted. In such cases, the current transaction is rolled back, which also includes setting the client variables as they were before the run of this transaction (it is assumed that one transaction script contains only one transaction; see \u003ca href=\"/docs/18/pgbench.html#TRANSACTIONS-AND-SCRIPTS\" rel=\"nofollow\"\u003eWhat Is the \u0026#34;Transaction\u0026#34; Actually Performed in pgbench?\u003c/a\u003e for more information). Transactions with serialization or deadlock errors are repeated after rollbacks until they complete successfully or reach the maximum number of tries (specified by the \u003ccode\u003e--max-tries\u003c/code\u003e option) / the maximum time of retries (specified by the \u003ccode\u003e--latency-limit\u003c/code\u003e option) / the end of benchmark (specified by the \u003ccode\u003e--time\u003c/code\u003e option). If the last trial run fails, this transaction will be reported as failed but the client is not aborted and continues to work.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eWithout specifying the \u003ccode\u003e--max-tries\u003c/code\u003e option, a transaction will never be retried after a serialization or deadlock error because its default value is 1. Use an unlimited number of tries (\u003ccode\u003e--max-tries=0\u003c/code\u003e) and the \u003ccode\u003e--latency-limit\u003c/code\u003e option to limit only the maximum time of tries. You can also use the \u003ccode\u003e--time\u003c/code\u003e option to limit the benchmark duration under an unlimited number of tries.\u003c/p\u003e\n\u003cp\u003eBe careful when repeating scripts that contain multiple transactions: the script is always retried completely, so successful transactions can be performed several times.\u003c/p\u003e\n\u003cp\u003eBe careful when repeating transactions with shell commands. Unlike the results of SQL commands, the results of shell commands are not rolled back, except for the variable value of the \u003ccode\u003e\\setshell\u003c/code\u003e command.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThe latency of a successful transaction includes the entire time of transaction execution with rollbacks and retries. The latency is measured only for successful transactions and commands but not for failed transactions or commands.\u003c/p\u003e\n\u003cp\u003eThe main report contains the number of failed transactions. If the \u003ccode\u003e--max-tries\u003c/code\u003e option is not equal to 1, the main report also contains statistics related to retries: the total number of retried transactions and total number of retries. The per-script report inherits all these fields from the main report. The per-statement report displays retry statistics only if the \u003ccode\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003cp\u003eIf you want to group failures by basic types in per-transaction and aggregation logs, as well as in the main and per-script reports, use the \u003ccode\u003e--failures-detailed\u003c/code\u003e option. If you also want to distinguish all errors and failures (errors without retrying) by type including which limit for retries was exceeded and how much it was exceeded by for the serialization/deadlock failures, use the \u003ccode\u003e--verbose-errors\u003c/code\u003e option.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.10\"\u003e\n\u003ch3\u003eTable Access Methods\u003c/h3\u003e\n\u003cp\u003eYou may specify the \u003ca href=\"/docs/18/tableam.html\" rel=\"nofollow\"\u003eTable Access Method\u003c/a\u003e for the pgbench tables. The environment variable \u003ccode\u003ePGOPTIONS\u003c/code\u003e specifies database configuration options that are passed to PostgreSQL via the command line (See \u003ca href=\"/docs/18/config-setting.html#CONFIG-SETTING-SHELL\" rel=\"nofollow\"\u003eSection 19.1.4\u003c/a\u003e). For example, a hypothetical default Table Access Method for the tables that pgbench creates called \u003ccode\u003ewuzza\u003c/code\u003e can be specified with:\u003c/p\u003e\n\u003cpre\u003ePGOPTIONS=\u0026#39;-c default_table_access_method=wuzza\u0026#39;\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.11\"\u003e\n\u003ch3\u003eGood Practices\u003c/h3\u003e\n\u003cp\u003eIt is very easy to use \u003cspan\u003epgbench\u003c/span\u003e to produce completely meaningless numbers. Here are some guidelines to help you get useful results.\u003c/p\u003e\n\u003cp\u003eIn the first place, \u003cspan\u003e\u003cem\u003enever\u003c/em\u003e\u003c/span\u003e believe any test that runs for only a few seconds. Use the \u003ccode\u003e-t\u003c/code\u003e or \u003ccode\u003e-T\u003c/code\u003e option 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\u0026#39;s a good idea to try the test run a few times, to find out if your numbers are reproducible or not.\u003c/p\u003e\n\u003cp\u003eFor the default TPC-B-like test scenario, the initialization scale factor (\u003ccode\u003e-s\u003c/code\u003e) should be at least as large as the largest number of clients you intend to test (\u003ccode\u003e-c\u003c/code\u003e); else you\u0026#39;ll mostly be measuring update contention. There are only \u003ccode\u003e-s\u003c/code\u003e rows in the \u003ccode\u003epgbench_branches\u003c/code\u003e table, and every transaction wants to update one of them, so \u003ccode\u003e-c\u003c/code\u003e values in excess of \u003ccode\u003e-s\u003c/code\u003e will undoubtedly result in lots of transactions blocked waiting for other transactions.\u003c/p\u003e\n\u003cp\u003eThe default test scenario is also quite sensitive to how long it\u0026#39;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.\u003c/p\u003e\n\u003cp\u003eA limitation of \u003cspan\u003epgbench\u003c/span\u003e is that it can itself become the bottleneck when trying to test a large number of client sessions. This can be alleviated by running \u003cspan\u003epgbench\u003c/span\u003e on a different machine from the database server, although low network latency will be essential. It might even be useful to run several \u003cspan\u003epgbench\u003c/span\u003e instances concurrently, on several client machines, against the same database server.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.11.9.12\"\u003e\n\u003ch3\u003eSecurity\u003c/h3\u003e\n\u003cp\u003eIf untrusted users have access to a database that has not adopted a \u003ca href=\"/docs/18/ddl-schemas.html#DDL-SCHEMAS-PATTERNS\" rel=\"nofollow\"\u003esecure schema usage pattern\u003c/a\u003e, do not run \u003cspan\u003epgbench\u003c/span\u003e in that database. \u003cspan\u003epgbench\u003c/span\u003e uses unqualified names and does not manipulate the search path.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"a291de8b70057110b5a185de6a8c44997139d4ef6d83f5989a034b1dfe1f40e2","Payload":{"description":["pgbench — run a benchmark test on PostgreSQL"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"PGBENCH\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epgbench — run a benchmark test on \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.11.4.1\"\u003e\u003ccode class=\"command\"\u003epgbench\u003c/code\u003e \u003ccode class=\"option\"\u003e-i\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.11.4.2\"\u003e\u003ccode class=\"command\"\u003epgbench\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e is a simple program for running benchmark tests on \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. 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, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e tests a scenario that is loosely based on TPC-B, involving five \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e, \u003ccode class=\"command\"\u003eUPDATE\u003c/code\u003e, and \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e commands per transaction. However, it is easy to test other cases by writing your own transaction script files.\u003c/p\u003e\n\u003cp\u003eTypical output from \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e looks like:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003etransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 10\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nlatency average = 11.013 ms\nlatency stddev = 7.351 ms\ninitial connection time = 45.758 ms\ntps = 896.967014 (without initial connection time)\n\u003c/pre\u003e\n\u003cp\u003eThe first seven lines report some of the most important parameter settings. The sixth line reports the maximum number of tries for transactions with serialization or deadlock errors (see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information). The eighth line reports the number of transactions completed and intended (the latter being just the product of number of clients and number of transactions per client); these will be equal unless the run failed before completion or some SQL command(s) failed. (In \u003ccode class=\"option\"\u003e-T\u003c/code\u003e mode, only the actual number of transactions is printed.) The next line reports the number of failed transactions due to serialization or deadlock errors (see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information). The last line reports the number of transactions per second.\u003c/p\u003e\n\u003cp\u003eThe default TPC-B-like transaction test requires specific tables to be set up beforehand. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e should be invoked with the \u003ccode class=\"option\"\u003e-i\u003c/code\u003e (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:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epgbench -i [\u003cspan class=\"optional\"\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eother-options\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003ewhere \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e is the name of the already-created database to test in. (You may also need \u003ccode class=\"option\"\u003e-h\u003c/code\u003e, \u003ccode class=\"option\"\u003e-p\u003c/code\u003e, and/or \u003ccode class=\"option\"\u003e-U\u003c/code\u003e options to specify how to connect to the database server.)\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epgbench -i\u003c/code\u003e creates four tables \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e, and \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e, destroying any existing tables of these names. Be very careful to use another database if you have tables having these names!\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eAt the default \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003escale factor\u003c/span\u003e”\u003c/span\u003e of 1, the tables initially contain this many rows:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003etable                   # of rows\n---------------------------------\npgbench_branches        1\npgbench_tellers         10\npgbench_accounts        100000\npgbench_history         0\n\u003c/pre\u003e\n\u003cp\u003eYou can (and, for most purposes, probably should) increase the number of rows by using the \u003ccode class=\"option\"\u003e-s\u003c/code\u003e (scale factor) option. The \u003ccode class=\"option\"\u003e-F\u003c/code\u003e (fillfactor) option might also be used at this point.\u003c/p\u003e\n\u003cp\u003eOnce you have done the necessary setup, you can run your benchmark with a command that doesn't include \u003ccode class=\"option\"\u003e-i\u003c/code\u003e, that is\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epgbench [\u003cspan class=\"optional\"\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e \u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003eIn nearly all cases, you'll need some options to make a useful test. The most important options are \u003ccode class=\"option\"\u003e-c\u003c/code\u003e (number of clients), \u003ccode class=\"option\"\u003e-t\u003c/code\u003e (number of transactions), \u003ccode class=\"option\"\u003e-T\u003c/code\u003e (time limit), and \u003ccode class=\"option\"\u003e-f\u003c/code\u003e (specify a custom script file). See below for a full list.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003eThe following is divided into three subsections. Different options are used during database initialization and while running benchmarks, but some options are useful in both cases.\u003c/p\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-INIT-OPTIONS\"\u003e\n\u003ch3\u003eInitialization Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e accepts the following command-line initialization arguments:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-DBNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e[\u003cspan class=\"optional\"\u003e-d\u003c/span\u003e] \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e[\u003cspan class=\"optional\"\u003e--dbname=\u003c/span\u003e]\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the name of the database to test in. If this is not specified, the environment variable \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e is used. If that is not set, the user name specified for the connection is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INITIALIZE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-i\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--initialize\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequired to invoke initialization mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-I \u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--init-steps=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform just a selected set of the normal initialization steps. \u003cem class=\"replaceable\"\u003e\u003ccode\u003einit_steps\u003c/code\u003e\u003c/em\u003e specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is \u003ccode class=\"literal\"\u003edtgvp\u003c/code\u003e. The available steps are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-D\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ed\u003c/code\u003e (Drop)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDrop any existing \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-T\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e (create Tables)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate the tables used by the standard \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e scenario, namely \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e, and \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-G\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eg\u003c/code\u003e or \u003ccode class=\"literal\"\u003eG\u003c/code\u003e (Generate data, client-side or server-side)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGenerate data and load it into the standard tables, replacing any data already present.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode class=\"literal\"\u003eg\u003c/code\u003e (client-side data generation), data is generated in \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e client and then sent to the server. This uses the client/server bandwidth extensively through a \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e. \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e uses the \u003ccode class=\"option\"\u003eFREEZE\u003c/code\u003e option to load data into ordinary (non-partition) tables with version 14 or later of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e to speed up subsequent \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e. Using \u003ccode class=\"literal\"\u003eg\u003c/code\u003e causes logging to print one message every 100,000 rows while generating data for all tables.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode class=\"literal\"\u003eG\u003c/code\u003e (server-side data generation), only small queries are sent from the \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e client and then data is actually generated in the server. No significant bandwidth is required for this variant, but the server will do more work. Using \u003ccode class=\"literal\"\u003eG\u003c/code\u003e causes logging not to print any progress message while generating data.\u003c/p\u003e\n\u003cp\u003eThe default initialization behavior uses client-side data generation (equivalent to \u003ccode class=\"literal\"\u003eg\u003c/code\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-V\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ev\u003c/code\u003e (Vacuum)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eInvoke \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e on the standard tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-P\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ep\u003c/code\u003e (create Primary keys)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate primary key indexes on the standard tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INIT-STEPS-F\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ef\u003c/code\u003e (create Foreign keys)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate foreign key constraints between the standard tables. (Note that this step is not performed by default.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FILLFACTOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--fillfactor=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efillfactor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate the \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e and \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e tables with the given fillfactor. Default is 100.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-NO-VACUUM-INIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform no vacuuming during initialization. (This option suppresses the \u003ccode class=\"literal\"\u003ev\u003c/code\u003e initialization step, even if it was specified in \u003ccode class=\"option\"\u003e-I\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-QUIET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-q\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware).\u003c/p\u003e\n\u003cp\u003eThis setting has no effect if \u003ccode class=\"literal\"\u003eG\u003c/code\u003e is specified in \u003ccode class=\"option\"\u003e-I\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SCALE-INIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--scale=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eMultiply the number of rows generated by the scale factor. For example, \u003ccode class=\"literal\"\u003e-s 100\u003c/code\u003e will create 10,000,000 rows in the \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers (\u003ccode class=\"structfield\"\u003eaid\u003c/code\u003e columns) will switch to using larger integers (\u003ccode class=\"type\"\u003ebigint\u003c/code\u003e), in order to be big enough to hold the range of account identifiers.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FOREIGN-KEYS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--foreign-keys\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate foreign key constraints between the standard tables. (This option adds the \u003ccode class=\"literal\"\u003ef\u003c/code\u003e step to the initialization step sequence, if it is not already present.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-INDEX-TABLESPACE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--index-tablespace=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex_tablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate indexes in the specified tablespace, rather than the default tablespace.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PARTITION-METHOD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--partition-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a partitioned \u003ccode class=\"literal\"\u003epgbench_accounts\u003c/code\u003e table with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNAME\u003c/code\u003e\u003c/em\u003e method. Expected values are \u003ccode class=\"literal\"\u003erange\u003c/code\u003e or \u003ccode class=\"literal\"\u003ehash\u003c/code\u003e. This option requires that \u003ccode class=\"option\"\u003e--partitions\u003c/code\u003e is set to non-zero. If unspecified, default is \u003ccode class=\"literal\"\u003erange\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PARTITIONS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--partitions=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate a partitioned \u003ccode class=\"literal\"\u003epgbench_accounts\u003c/code\u003e table with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eNUM\u003c/code\u003e\u003c/em\u003e partitions of nearly equal size for the scaled number of accounts. Default is \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, meaning no partitioning.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TABLESPACE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tablespace=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etablespace\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate tables in the specified tablespace, rather than the default tablespace.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-UNLOGGED-TABLES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--unlogged-tables\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreate all tables as unlogged tables, rather than permanent tables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-RUN-OPTIONS\"\u003e\n\u003ch3\u003eBenchmarking Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e accepts the following command-line benchmarking arguments:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-BUILTIN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-b\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--builtin\u003c/code\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAdd the specified built-in script to the list of scripts to be executed. Available built-in scripts are: \u003ccode class=\"literal\"\u003etpcb-like\u003c/code\u003e, \u003ccode class=\"literal\"\u003esimple-update\u003c/code\u003e and \u003ccode class=\"literal\"\u003eselect-only\u003c/code\u003e. Unambiguous prefixes of built-in names are accepted. With the special name \u003ccode class=\"literal\"\u003elist\u003c/code\u003e, show the list of built-in scripts and exit immediately.\u003c/p\u003e\n\u003cp\u003eOptionally, write an integer weight after \u003ccode class=\"literal\"\u003e@\u003c/code\u003e to adjust the probability of selecting this script versus other ones. The default weight is 1. See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-CLIENT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--client=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eclients\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of clients simulated, that is, number of concurrent database sessions. Default is 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-CONNECT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--connect\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEstablish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-DEFINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--define=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefine a variable for use by a custom script (see below). Multiple \u003ccode class=\"option\"\u003e-D\u003c/code\u003e options are allowed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename[@weight]\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAdd a transaction script read from \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e to the list of scripts to be executed.\u003c/p\u003e\n\u003cp\u003eOptionally, write an integer weight after \u003ccode class=\"literal\"\u003e@\u003c/code\u003e to adjust the probability of selecting this script versus other ones. The default weight is 1. (To use a script file name that includes an \u003ccode class=\"literal\"\u003e@\u003c/code\u003e character, append a weight so that there is no ambiguity, for example \u003ccode class=\"literal\"\u003efilen@me@1\u003c/code\u003e.) See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-JOBS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-j\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--jobs=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ethreads\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of worker threads within \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e. Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LOG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite information about each transaction to a log file. See below for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LATENCY-LIMIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--latency-limit=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTransactions that last more than \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e milliseconds are counted and reported separately, as \u003cem class=\"firstterm\"\u003elate\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eWhen throttling is used (\u003ccode class=\"option\"\u003e--rate=...\u003c/code\u003e), transactions that lag behind schedule by more than \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e ms, and thus have no hope of meeting the latency limit, are not sent to the server at all. They are counted and reported separately as \u003cem class=\"firstterm\"\u003eskipped\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is used, a transaction which fails due to a serialization anomaly or from a deadlock will not be retried if the total time of all its tries is greater than \u003cem class=\"replaceable\"\u003e\u003ccode\u003elimit\u003c/code\u003e\u003c/em\u003e ms. To limit only the time of tries and not their number, use \u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e. By default, the option \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is set to 1 and transactions with serialization/deadlock errors are not retried. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information about retrying such transactions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROTOCOL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-M\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--protocol=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003equerymode\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eProtocol to use for submitting queries to the server:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003esimple\u003c/code\u003e: use simple query protocol.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eextended\u003c/code\u003e: use extended query protocol.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eprepared\u003c/code\u003e: use extended query protocol with prepared statements.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eIn the \u003ccode class=\"literal\"\u003eprepared\u003c/code\u003e mode, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e reuses the parse analysis result starting from the second query iteration, so \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e runs faster than in other modes.\u003c/p\u003e\n\u003cp\u003eThe default is simple query protocol. (See \u003ca class=\"xref\" href=\"/docs/18/protocol.html\" title=\"Chapter 54. Frontend/Backend Protocol\"\u003eChapter 54\u003c/a\u003e for more information.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-NO-VACUUM-RUN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-vacuum\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform no vacuuming before running the test. This option is \u003cspan class=\"emphasis\"\u003e\u003cem\u003enecessary\u003c/em\u003e\u003c/span\u003e if you are running a custom test scenario that does not include the standard tables \u003ccode class=\"structname\"\u003epgbench_accounts\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e, \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e, and \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SKIP-SOME-UPDATES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--skip-some-updates\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun built-in simple-update script. Shorthand for \u003ccode class=\"option\"\u003e-b simple-update\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROGRESS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow progress report every \u003cem class=\"replaceable\"\u003e\u003ccode\u003esec\u003c/code\u003e\u003c/em\u003e seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling (\u003ccode class=\"option\"\u003e-R\u003c/code\u003e), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-REPORT-LATENCIES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-r\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--report-per-command\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-RATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--rate=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExecute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results.\u003c/p\u003e\n\u003cp\u003eThe rate is targeted by starting transactions along a Poisson-distributed schedule time line. The expected start time schedule moves forward based on when the client first started, not when the previous transaction ended. That approach means that when transactions go past their original scheduled end time, it is possible for later ones to catch up again.\u003c/p\u003e\n\u003cp\u003eWhen throttling is active, the transaction latency reported at the end of the run is calculated from the scheduled start times, so it includes the time each transaction had to wait for the previous transaction to finish. The wait time is called the schedule lag time, and its average and maximum are also reported separately. The transaction latency with respect to the actual transaction start time, i.e., the time spent executing the transaction in the database, can be computed by subtracting the schedule lag time from the reported latency.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e is used together with \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e, a transaction can lag behind so much that it is already over the latency limit when the previous transaction ends, because the latency is calculated from the scheduled start time. Such transactions are not sent to the server, but are skipped altogether and counted separately.\u003c/p\u003e\n\u003cp\u003eA high schedule lag time is an indication that the system cannot process transactions at the specified rate, with the chosen number of clients and threads. When the average transaction execution time is longer than the scheduled interval between each transaction, each successive transaction will fall further behind, and the schedule lag time will keep increasing the longer the test run is. When that happens, you will have to reduce the specified transaction rate.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SCALE-RUN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--scale=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escale_factor\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport the specified scale factor in \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e'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 \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e table. However, when testing only custom benchmarks (\u003ccode class=\"option\"\u003e-f\u003c/code\u003e option), the scale factor will be reported as 1 unless this option is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SELECT-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--select-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun built-in select-only script. Shorthand for \u003ccode class=\"option\"\u003e-b select-only\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TRANSACTIONS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--transactions=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNumber of transactions each client runs. Default is 10.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-TIME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--time=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun the test for this many seconds, rather than a fixed number of transactions per client. \u003ccode class=\"option\"\u003e-t\u003c/code\u003e and \u003ccode class=\"option\"\u003e-T\u003c/code\u003e are mutually exclusive.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VACUUM-ALL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--vacuum-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eVacuum all four standard tables before running the test. With neither \u003ccode class=\"option\"\u003e-n\u003c/code\u003e nor \u003ccode class=\"option\"\u003e-v\u003c/code\u003e, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e will vacuum the \u003ccode class=\"structname\"\u003epgbench_tellers\u003c/code\u003e and \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e tables, and will truncate \u003ccode class=\"structname\"\u003epgbench_history\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-AGGREGATE-INTERVAL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--aggregate-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLength of aggregation interval (in seconds). May be used only with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e option. With this option, the log contains per-interval summary data, as described below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-EXIT-ON-ABORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by \u003ccode class=\"option\"\u003e-t\u003c/code\u003e or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e option, and \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e will print an incomplete results in this case.\u003c/p\u003e\n\u003cp\u003eNote that serialization failures or deadlock failures do not abort the client, so they are not affected by this option. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-FAILURES-DETAILED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReport failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eserialization failures;\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003edeadlock failures;\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eSee \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-LOG-PREFIX\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log-prefix=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the filename prefix for the log files created by \u003ccode class=\"option\"\u003e--log\u003c/code\u003e. The default is \u003ccode class=\"literal\"\u003epgbench_log\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-MAX-TRIES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--max-tries=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_of_tries\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries (\u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e) without \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e or \u003ccode class=\"option\"\u003e--time\u003c/code\u003e. The default value is 1 and transactions with serialization/deadlock errors are not retried. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information about retrying such transactions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PROGRESS-TIMESTAMP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress-timestamp\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen showing progress (option \u003ccode class=\"option\"\u003e-P\u003c/code\u003e), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-RANDOM-SEED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--random-seed=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e may be: \u003ccode class=\"literal\"\u003etime\u003c/code\u003e (the default, the seed is based on the current time), \u003ccode class=\"literal\"\u003erand\u003c/code\u003e (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script (\u003ccode class=\"literal\"\u003erandom...\u003c/code\u003e functions) or implicitly (for instance option \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e may also be provided through the environment variable \u003ccode class=\"literal\"\u003ePGBENCH_RANDOM_SEED\u003c/code\u003e. To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable.\u003c/p\u003e\n\u003cp\u003eSetting the seed explicitly allows to reproduce a \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e run exactly, as far as random numbers are concerned. As the random state is managed per thread, this means the exact same \u003ccode class=\"command\"\u003epgbench\u003c/code\u003e run for an identical invocation if there is one client per thread and there are no external or data dependencies. From a statistical viewpoint reproducing runs exactly is a bad idea because it can hide the performance variability or improve performance unduly, e.g., by hitting the same pages as a previous run. However, it may also be of great help for debugging, for instance re-running a tricky case which leads to an error. Use wisely.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SAMPLING-RATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sampling-rate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged.\u003c/p\u003e\n\u003cp\u003eRemember to take the sampling rate into account when processing the log file. For example, when computing TPS values, you need to multiply the numbers accordingly (e.g., with 0.01 sample rate, you'll only get 1/100 of the actual TPS).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-SHOW-SCRIPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--show-script=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow the actual code of builtin script \u003cem class=\"replaceable\"\u003e\u003ccode\u003escriptname\u003c/code\u003e\u003c/em\u003e on stderr, and exit immediately.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VERBOSE-ERRORS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-COMMON-OPTIONS\"\u003e\n\u003ch3\u003eCommon Options\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e also accepts the following common command-line arguments for connection parameters and other common settings:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-OPTION-DEBUG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--debug\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint debugging output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server's host name\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-PORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server's port number\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-USERNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elogin\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe user name to connect as\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-OPTION-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003eA successful run will exit with status 0. Exit status 1 indicates static problems such as invalid command-line options or internal errors which are supposed to never occur. Early errors that occur when starting benchmark such as initial connection failures also exit with status 1. Errors during the run such as database errors or problems in the script will result in exit status 2. In the latter case, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e will print partial results if \u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e option is not specified.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.8\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-ENVIRONMENT-PGDATABASE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.11.9\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cdiv class=\"refsect2\" id=\"TRANSACTIONS-AND-SCRIPTS\"\u003e\n\u003ch3\u003eWhat Is the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eTransaction\u003c/span\u003e”\u003c/span\u003e Actually Performed in \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e?\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e executes test scripts chosen randomly from a specified list. The scripts may include built-in scripts specified with \u003ccode class=\"option\"\u003e-b\u003c/code\u003e and user-provided scripts specified with \u003ccode class=\"option\"\u003e-f\u003c/code\u003e. Each script may be given a relative weight specified after an \u003ccode class=\"literal\"\u003e@\u003c/code\u003e so as to change its selection probability. The default weight is \u003ccode class=\"literal\"\u003e1\u003c/code\u003e. Scripts with a weight of \u003ccode class=\"literal\"\u003e0\u003c/code\u003e are ignored.\u003c/p\u003e\n\u003cp\u003eThe default built-in transaction script (also invoked with \u003ccode class=\"option\"\u003e-b tpcb-like\u003c/code\u003e) issues seven commands per transaction over randomly chosen \u003ccode class=\"literal\"\u003eaid\u003c/code\u003e, \u003ccode class=\"literal\"\u003etid\u003c/code\u003e, \u003ccode class=\"literal\"\u003ebid\u003c/code\u003e and \u003ccode class=\"literal\"\u003edelta\u003c/code\u003e. The scenario is inspired by the TPC-B benchmark, but is not actually TPC-B, hence the name.\u003c/p\u003e\n\u003cdiv class=\"orderedlist\"\u003e\n\u003col class=\"orderedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eBEGIN;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eUPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eSELECT abalance FROM pgbench_accounts WHERE aid = :aid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eUPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eUPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eINSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eEND;\u003c/code\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n\u003cp\u003eIf you select the \u003ccode class=\"literal\"\u003esimple-update\u003c/code\u003e built-in (also \u003ccode class=\"option\"\u003e-N\u003c/code\u003e), steps 4 and 5 aren't included in the transaction. This will avoid update contention on these tables, but it makes the test case even less like TPC-B.\u003c/p\u003e\n\u003cp\u003eIf you select the \u003ccode class=\"literal\"\u003eselect-only\u003c/code\u003e built-in (also \u003ccode class=\"option\"\u003e-S\u003c/code\u003e), only the \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e is issued.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.3\"\u003e\n\u003ch3\u003eCustom Scripts\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e has support for running custom benchmark scenarios by replacing the default transaction script (described above) with a transaction script read from a file (\u003ccode class=\"option\"\u003e-f\u003c/code\u003e option). In this case a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etransaction\u003c/span\u003e”\u003c/span\u003e counts as one execution of a script file.\u003c/p\u003e\n\u003cp\u003eA script file contains one or more SQL commands terminated by semicolons. Empty lines and lines beginning with \u003ccode class=\"literal\"\u003e--\u003c/code\u003e are ignored. Script files can also contain \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003emeta commands\u003c/span\u003e”\u003c/span\u003e, which are interpreted by \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e itself, as described below.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eBefore \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, SQL commands in script files were terminated by newlines, and so they could not be continued across lines. Now a semicolon is \u003cspan class=\"emphasis\"\u003e\u003cem\u003erequired\u003c/em\u003e\u003c/span\u003e to separate consecutive SQL commands (though an SQL command does not need one if it is followed by a meta command). If you need to create a script file that works with both old and new versions of \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e, be sure to write each SQL command on a single line ending with a semicolon.\u003c/p\u003e\n\u003cp\u003eIt is assumed that \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e scripts do not contain incomplete blocks of SQL transactions. If at runtime the client reaches the end of the script without completing the last transaction block, it will be aborted.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThere is a simple variable-substitution facility for script files. Variable names must consist of letters (including non-Latin letters), digits, and underscores, with the first character not being a digit. Variables can be set by the command-line \u003ccode class=\"option\"\u003e-D\u003c/code\u003e option, explained above, or by the meta commands explained below. In addition to any variables preset by \u003ccode class=\"option\"\u003e-D\u003c/code\u003e command-line options, there are a few variables that are preset automatically, listed in \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#PGBENCH-AUTOMATIC-VARIABLES\" title=\"Table 301. pgbench Automatic Variables\"\u003eTable 301\u003c/a\u003e. A value specified for these variables using \u003ccode class=\"option\"\u003e-D\u003c/code\u003e takes precedence over the automatic presets. Once set, a variable's value can be inserted into an SQL command by writing \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e. When running more than one client session, each session has its own set of variables. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e supports up to 255 variable uses in one statement.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"PGBENCH-AUTOMATIC-VARIABLES\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 301. pgbench Automatic Variables\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eVariable\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003eclient_id\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eunique number identifying the client session (starts from zero)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003edefault_seed\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003eseed used in hash and pseudorandom permutation functions by default\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003erandom_seed\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003erandom generator seed (unless overwritten with \u003ccode class=\"option\"\u003e-D\u003c/code\u003e)\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ccode class=\"literal\"\u003escale\u003c/code\u003e\u003c/td\u003e\n\u003ctd\u003ecurrent scale factor\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eScript file meta commands begin with a backslash (\u003ccode class=\"literal\"\u003e\\\u003c/code\u003e) and normally extend to the end of the line, although they can be continued to additional lines by writing backslash-return. Arguments to a meta command are separated by white space. These meta commands are supported:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-GSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gset [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e \u003ccode class=\"literal\"\u003e\\aset [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese commands may be used to end SQL queries, taking the place of the terminating semicolon (\u003ccode class=\"literal\"\u003e;\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"literal\"\u003e\\gset\u003c/code\u003e command is used, the preceding SQL query is expected to return one row, the columns of which are stored into variables named after column names, and prefixed with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e if provided.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"literal\"\u003e\\aset\u003c/code\u003e command is used, all combined SQL queries (separated by \u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e) have their columns stored into variables named after column names, and prefixed with \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e if provided. If a query returns no row, no assignment is made and the variable can be tested for existence to detect this. If a query returns more than one row, the last value is kept.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\gset\u003c/code\u003e and \u003ccode class=\"literal\"\u003e\\aset\u003c/code\u003e cannot be used in pipeline mode, since the query results are not yet available by the time the commands would need them.\u003c/p\u003e\n\u003cp\u003eThe following example puts the final account balance from the first query into variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003eabalance\u003c/code\u003e\u003c/em\u003e, and fills variables \u003cem class=\"replaceable\"\u003e\u003ccode\u003ep_two\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ep_three\u003c/code\u003e\u003c/em\u003e with integers from the third query. The result of the second query is discarded. The result of the two last combined queries are stored in variables \u003cem class=\"replaceable\"\u003e\u003ccode\u003efour\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003efive\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eUPDATE pgbench_accounts\n  SET abalance = abalance + :delta\n  WHERE aid = :aid\n  RETURNING abalance \\gset\n-- compound of two queries\nSELECT 1 \\;\nSELECT 2 AS two, 3 AS three \\gset p_\nSELECT 4 AS four \\; SELECT 5 AS five \\aset\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-IF-ELSE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\if\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\elif\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\else\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endif\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements nestable conditional blocks, similarly to \u003ccode class=\"literal\"\u003epsql\u003c/code\u003e's \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#PSQL-METACOMMAND-IF\"\u003e\u003ccode class=\"literal\"\u003e\\if\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e. Conditional expressions are identical to those with \u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e, with non-zero values interpreted as true.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\set \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e to a value calculated from \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e. The expression may contain the \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e constant, Boolean constants \u003ccode class=\"literal\"\u003eTRUE\u003c/code\u003e and \u003ccode class=\"literal\"\u003eFALSE\u003c/code\u003e, integer constants such as \u003ccode class=\"literal\"\u003e5432\u003c/code\u003e, double constants such as \u003ccode class=\"literal\"\u003e3.14159\u003c/code\u003e, references to variables \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e, \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-BUILTIN-OPERATORS\" title=\"Built-in Operators\"\u003eoperators\u003c/a\u003e with their usual SQL precedence and associativity, \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-BUILTIN-FUNCTIONS\" title=\"Built-In Functions\"\u003efunction calls\u003c/a\u003e, SQL \u003ca class=\"link\" href=\"/docs/18/functions-conditional.html#FUNCTIONS-CASE\" title=\"9.18.1. CASE\"\u003e\u003ccode class=\"token\"\u003eCASE\u003c/code\u003e generic conditional expressions\u003c/a\u003e and parentheses.\u003c/p\u003e\n\u003cp\u003eFunctions and most operators return \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e on \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e input.\u003c/p\u003e\n\u003cp\u003eFor conditional purposes, non zero numerical values are \u003ccode class=\"literal\"\u003eTRUE\u003c/code\u003e, zero numerical values and \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e are \u003ccode class=\"literal\"\u003eFALSE\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eToo large or small integer and double constants, as well as integer arithmetic operators (\u003ccode class=\"literal\"\u003e+\u003c/code\u003e, \u003ccode class=\"literal\"\u003e-\u003c/code\u003e, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e and \u003ccode class=\"literal\"\u003e/\u003c/code\u003e) raise errors on overflows.\u003c/p\u003e\n\u003cp\u003eWhen no final \u003ccode class=\"token\"\u003eELSE\u003c/code\u003e clause is provided to a \u003ccode class=\"token\"\u003eCASE\u003c/code\u003e, the default value is \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set ntellers 10 * :scale\n\\set aid (1021 * random(1, 100000 * :scale)) % \\\n           (100000 * :scale) + 1\n\\set divx CASE WHEN :x \u0026lt;\u0026gt; 0 THEN :y/:x ELSE NULL END\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SLEEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sleep \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [ us | ms | s ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCauses script execution to sleep for the specified duration in microseconds (\u003ccode class=\"literal\"\u003eus\u003c/code\u003e), milliseconds (\u003ccode class=\"literal\"\u003ems\u003c/code\u003e) or seconds (\u003ccode class=\"literal\"\u003es\u003c/code\u003e). If the unit is omitted then seconds are the default. \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e can be either an integer constant or a \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e reference to a variable having an integer value.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\sleep 10 ms\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SETSHELL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\setshell \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003evarname\u003c/code\u003e\u003c/em\u003e to the result of the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e with the given \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e(s). The command must return an integer value through its standard output.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e and each \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e can be either a text constant or a \u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariablename\u003c/code\u003e\u003c/em\u003e reference to a variable. If you want to use an \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e starting with a colon, write an additional colon at the beginning of \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\setshell variable_to_be_assigned command literal_argument :variable ::literal_starting_with_colon\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-SHELL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\shell \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargument\u003c/code\u003e\u003c/em\u003e ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSame as \u003ccode class=\"literal\"\u003e\\setshell\u003c/code\u003e, but the result of the command is discarded.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\shell command literal_argument :variable ::literal_starting_with_colon\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PGBENCH-METACOMMAND-PIPELINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\startpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\syncpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endpipeline\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements pipelining of SQL statements. A pipeline must begin with a \u003ccode class=\"command\"\u003e\\startpipeline\u003c/code\u003e and end with an \u003ccode class=\"command\"\u003e\\endpipeline\u003c/code\u003e. In between there may be any number of \u003ccode class=\"command\"\u003e\\syncpipeline\u003c/code\u003e commands, which sends a \u003ca class=\"link\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY\" title=\"54.2.3. Extended Query\"\u003esync message\u003c/a\u003e without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See \u003ca class=\"xref\" href=\"/docs/18/libpq-pipeline-mode.html\" title=\"32.5. Pipeline Mode\"\u003eSection 32.5\u003c/a\u003e for more details. Pipeline mode requires the use of extended query protocol.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-BUILTIN-OPERATORS\"\u003e\n\u003ch3\u003eBuilt-in Operators\u003c/h3\u003e\n\u003cp\u003eThe arithmetic, bitwise, comparison and logical operators listed in \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#PGBENCH-OPERATORS\" title=\"Table 302. pgbench Operators\"\u003eTable 302\u003c/a\u003e are built into \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e and may be used in expressions appearing in \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-METACOMMAND-SET\"\u003e\u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e\u003c/a\u003e. The operators are listed in increasing precedence order. Except as noted, operators taking two numeric inputs will produce a double value if either input is double, otherwise they produce an integer result.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"PGBENCH-OPERATORS\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 302. pgbench Operators\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003eOperator\u003c/p\u003e\n\u003cp\u003eDescription\u003c/p\u003e\n\u003cp\u003eExample(s)\u003c/p\u003e\n\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eOR\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical OR\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 or 0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eAND\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical AND\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e3 and 0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"literal\"\u003eNOT\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLogical NOT\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003enot false\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eIS [NOT] (NULL|TRUE|FALSE)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBoolean value tests\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 is null\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003eISNULL|NOTNULL\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNullness tests\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 notnull\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eEqual\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 = 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;\u0026gt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNot equal\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026lt;\u0026gt; 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e!=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNot equal\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 != 5\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLess than\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026lt; 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eLess than or equal to\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026lt;= 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eFALSE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026gt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eGreater than\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026gt; 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026gt;=\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eGreater than or equal to\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 \u0026gt;= 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003eTRUE\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e|\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise OR\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 | 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e3\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e#\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise XOR\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 # 3\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026amp;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise AND\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 \u0026amp; 3\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"literal\"\u003e~\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise NOT\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e~ 1\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026lt;\u0026lt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise shift left\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e1 \u0026lt;\u0026lt; 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e4\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e\u0026gt;\u0026gt;\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eBitwise shift right\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e8 \u0026gt;\u0026gt; 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e+\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eAddition\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 + 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e9\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e-\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSubtraction\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e3 - 2.0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e*\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eMultiplication\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 * 4\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e20\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e/\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eDivision (truncates the result towards zero if both inputs are integers)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e5 / 3\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"literal\"\u003e%\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eModulo (remainder)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e3 % 2\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"literal\"\u003e-\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e → \u003ccode class=\"returnvalue\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNegation\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e- 2.0\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-2.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"PGBENCH-BUILTIN-FUNCTIONS\"\u003e\n\u003ch3\u003eBuilt-In Functions\u003c/h3\u003e\n\u003cp\u003eThe functions listed in \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#PGBENCH-FUNCTIONS\" title=\"Table 303. pgbench Functions\"\u003eTable 303\u003c/a\u003e are built into \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e and may be used in expressions appearing in \u003ca class=\"link\" href=\"/docs/18/pgbench.html#PGBENCH-METACOMMAND-SET\"\u003e\u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"table\" id=\"PGBENCH-FUNCTIONS\"\u003e\n\u003cp class=\"title\"\u003e\u003cstrong\u003eTable 303. pgbench Functions\u003c/strong\u003e\u003c/p\u003e\n\u003cdiv class=\"table-contents\"\u003e\n\u003ctable class=\"table\"\u003e\n\n\n\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003eFunction\u003c/p\u003e\n\u003cp\u003eDescription\u003c/p\u003e\n\u003cp\u003eExample(s)\u003c/p\u003e\n\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eabs\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → same type as input\u003c/p\u003e\n\u003cp\u003eAbsolute value\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eabs(-17)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e17\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003edebug\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → same type as input\u003c/p\u003e\n\u003cp\u003ePrints the argument to \u003cspan class=\"systemitem\"\u003estderr\u003c/span\u003e, and returns the argument.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003edebug(5432.1)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e5432.1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003edouble\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eCasts to double.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003edouble(5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e5432.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eexp\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eExponential (\u003ccode class=\"literal\"\u003ee\u003c/code\u003e raised to the given power)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eexp(1.0)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2.718281828459045\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003egreatest\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003ccode class=\"literal\"\u003e...\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"type\"\u003edouble\u003c/code\u003e if any argument is double, else \u003ccode class=\"type\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSelects the largest value among the arguments.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003egreatest(5, 4, 3, 2)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e5\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003ehash\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eThis is an alias for \u003ccode class=\"function\"\u003ehash_murmur2\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ehash(10, 5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-5817877081768721676\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003ehash_fnv1a\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes \u003ca class=\"ulink\" href=\"https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function\"\u003eFNV-1a hash\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ehash_fnv1a(10, 5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-7793829335365542153\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003ehash_murmur2\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes \u003ca class=\"ulink\" href=\"https://en.wikipedia.org/wiki/MurmurHash\"\u003eMurmurHash2 hash\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ehash_murmur2(10, 5432)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e-5817877081768721676\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eint\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eCasts to integer.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eint(5.4 + 3.8)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e9\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eleast\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e [\u003cspan class=\"optional\"\u003e, \u003ccode class=\"literal\"\u003e...\u003c/code\u003e\u003c/span\u003e ] ) → \u003ccode class=\"type\"\u003edouble\u003c/code\u003e if any argument is double, else \u003ccode class=\"type\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSelects the smallest value among the arguments.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eleast(5, 4, 3, 2.1)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e2.1\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003eln\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eNatural logarithm\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eln(2.718281828459045)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003emod\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eModulo (remainder)\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003emod(54, 32)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e22\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epermute\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e [, \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e ] ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003ePermuted value of \u003cem class=\"parameter\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e, in the range \u003ccode class=\"literal\"\u003e[0, size)\u003c/code\u003e. This is the new position of \u003cem class=\"parameter\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e (modulo \u003cem class=\"parameter\"\u003e\u003ccode\u003esize\u003c/code\u003e\u003c/em\u003e) in a pseudorandom permutation of the integers \u003ccode class=\"literal\"\u003e0...size-1\u003c/code\u003e, parameterized by \u003cem class=\"parameter\"\u003e\u003ccode\u003eseed\u003c/code\u003e\u003c/em\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epermute(0, 4)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 0 and 3\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epi\u003c/code\u003e () → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eApproximate value of \u003cspan class=\"symbol_font\"\u003eπ\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epi()\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e3.14159265358979323846\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epow\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003epower\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ex\u003c/code\u003e\u003c/em\u003e raised to the power of \u003cem class=\"parameter\"\u003e\u003ccode\u003ey\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epow(2.0, 10)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1024.0\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a uniformly-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom(1, 10)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom_exponential\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes an exponentially-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_exponential(1, 10, 3.0)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom_gaussian\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a Gaussian-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_gaussian(1, 10, 2.5)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003erandom_zipfian\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003elb\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eub\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eComputes a Zipfian-distributed random integer in \u003ccode class=\"literal\"\u003e[lb, ub]\u003c/code\u003e, see below.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_zipfian(1, 10, 1.5)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003ean integer between 1 and 10\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"func_table_entry\"\u003e\n\u003cp class=\"func_signature\"\u003e\u003ccode class=\"function\"\u003esqrt\u003c/code\u003e ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/em\u003e ) → \u003ccode class=\"returnvalue\"\u003edouble\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eSquare root\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003esqrt(2.0)\u003c/code\u003e → \u003ccode class=\"returnvalue\"\u003e1.414213562\u003c/code\u003e\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003cbr class=\"table-break\"\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003erandom\u003c/code\u003e function generates values using a uniform distribution, that is all the values are drawn within the specified range with equal probability. The \u003ccode class=\"literal\"\u003erandom_exponential\u003c/code\u003e, \u003ccode class=\"literal\"\u003erandom_gaussian\u003c/code\u003e and \u003ccode class=\"literal\"\u003erandom_zipfian\u003c/code\u003e functions require an additional double parameter which determines the precise shape of the distribution.\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eFor an exponential distribution, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e controls the distribution by truncating a quickly-decreasing exponential distribution at \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, and then projecting onto integers between the bounds. To be precise, with\u003c/p\u003e\n\u003cdiv class=\"literallayout\"\u003e\n\u003cp\u003e\u003cbr\u003e\n              f(x) = exp(-parameter * (x - min) / (max - min + 1)) / (1 - exp(-parameter))\u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThen value \u003cem class=\"replaceable\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e between \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e inclusive is drawn with probability: \u003ccode class=\"literal\"\u003ef(i) - f(i + 1)\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIntuitively, the larger the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values close to \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e are accessed, and the less frequently values close to \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e are accessed. The closer to 0 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e is, the flatter (more uniform) the access distribution. A crude approximation of the distribution is that the most frequent 1% values in the range, close to \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e, are drawn \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e% of the time. The \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value must be strictly positive.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eFor a Gaussian distribution, the interval is mapped onto a standard normal distribution (the classical bell-shaped Gaussian curve) truncated at \u003ccode class=\"literal\"\u003e-parameter\u003c/code\u003e on the left and \u003ccode class=\"literal\"\u003e+parameter\u003c/code\u003e on the right. Values in the middle of the interval are more likely to be drawn. To be precise, if \u003ccode class=\"literal\"\u003ePHI(x)\u003c/code\u003e is the cumulative distribution function of the standard normal distribution, with mean \u003ccode class=\"literal\"\u003emu\u003c/code\u003e defined as \u003ccode class=\"literal\"\u003e(max + min) / 2.0\u003c/code\u003e, with\u003c/p\u003e\n\u003cdiv class=\"literallayout\"\u003e\n\u003cp\u003e\u003cbr\u003e\n              f(x) = PHI(2.0 * parameter * (x - mu) / (max - min + 1)) /\u003cbr\u003e\n                     (2.0 * PHI(parameter) - 1)\u003cbr\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003ethen value \u003cem class=\"replaceable\"\u003e\u003ccode\u003ei\u003c/code\u003e\u003c/em\u003e between \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e inclusive is drawn with probability: \u003ccode class=\"literal\"\u003ef(i + 0.5) - f(i - 0.5)\u003c/code\u003e. Intuitively, the larger the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values close to the middle of the interval are drawn, and the less frequently values close to the \u003cem class=\"replaceable\"\u003e\u003ccode\u003emin\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003emax\u003c/code\u003e\u003c/em\u003e bounds. About 67% of values are drawn from the middle \u003ccode class=\"literal\"\u003e1.0 / parameter\u003c/code\u003e, that is a relative \u003ccode class=\"literal\"\u003e0.5 / parameter\u003c/code\u003e around the mean, and 95% in the middle \u003ccode class=\"literal\"\u003e2.0 / parameter\u003c/code\u003e, that is a relative \u003ccode class=\"literal\"\u003e1.0 / parameter\u003c/code\u003e around the mean; for instance, if \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e is 4.0, 67% of values are drawn from the middle quarter (1.0 / 4.0) of the interval (i.e., from \u003ccode class=\"literal\"\u003e3.0 / 8.0\u003c/code\u003e to \u003ccode class=\"literal\"\u003e5.0 / 8.0\u003c/code\u003e) and 95% from the middle half (\u003ccode class=\"literal\"\u003e2.0 / 4.0\u003c/code\u003e) of the interval (second and third quartiles). The minimum allowed \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value is 2.0.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003erandom_zipfian\u003c/code\u003e generates a bounded Zipfian distribution. \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e defines how skewed the distribution is. The larger the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e, the more frequently values closer to the beginning of the interval are drawn. The distribution is such that, assuming the range starts from 1, the ratio of the probability of drawing \u003cem class=\"replaceable\"\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e versus drawing \u003cem class=\"replaceable\"\u003e\u003ccode\u003ek+1\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003e((\u003cem class=\"replaceable\"\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e+1)/\u003cem class=\"replaceable\"\u003e\u003ccode\u003ek\u003c/code\u003e\u003c/em\u003e)**\u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. For example, \u003ccode class=\"literal\"\u003erandom_zipfian(1, ..., 2.5)\u003c/code\u003e produces the value \u003ccode class=\"literal\"\u003e1\u003c/code\u003e about \u003ccode class=\"literal\"\u003e(2/1)**2.5 = 5.66\u003c/code\u003e times more frequently than \u003ccode class=\"literal\"\u003e2\u003c/code\u003e, which itself is produced \u003ccode class=\"literal\"\u003e(3/2)**2.5 = 2.76\u003c/code\u003e times more frequently than \u003ccode class=\"literal\"\u003e3\u003c/code\u003e, and so on.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epgbench\u003c/span\u003e's implementation is based on \"Non-Uniform Random Variate Generation\", Luc Devroye, p. 550-551, Springer 1986. Due to limitations of that algorithm, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e value is restricted to the range [1.001, 1000].\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhen designing a benchmark which selects rows non-uniformly, be aware that the rows chosen may be correlated with other data such as IDs from a sequence or the physical row ordering, which may skew performance measurements.\u003c/p\u003e\n\u003cp\u003eTo avoid this, you may wish to use the \u003ccode class=\"function\"\u003epermute\u003c/code\u003e function, or some other additional step with similar effect, to shuffle the selected rows and remove such correlations.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eHash functions \u003ccode class=\"literal\"\u003ehash\u003c/code\u003e, \u003ccode class=\"literal\"\u003ehash_murmur2\u003c/code\u003e and \u003ccode class=\"literal\"\u003ehash_fnv1a\u003c/code\u003e accept an input value and an optional seed parameter. In case the seed isn't provided the value of \u003ccode class=\"literal\"\u003e:default_seed\u003c/code\u003e is used, which is initialized randomly unless set by the command-line \u003ccode class=\"literal\"\u003e-D\u003c/code\u003e option.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epermute\u003c/code\u003e accepts an input value, a size, and an optional seed parameter. It generates a pseudorandom permutation of integers in the range \u003ccode class=\"literal\"\u003e[0, size)\u003c/code\u003e, and returns the index of the input value in the permuted values. The permutation chosen is parameterized by the seed, which defaults to \u003ccode class=\"literal\"\u003e:default_seed\u003c/code\u003e, if not specified. Unlike the hash functions, \u003ccode class=\"literal\"\u003epermute\u003c/code\u003e ensures that there are no collisions or holes in the output values. Input values outside the interval are interpreted modulo the size. The function raises an error if the size is not positive. \u003ccode class=\"function\"\u003epermute\u003c/code\u003e can be used to scatter the distribution of non-uniform random functions such as \u003ccode class=\"literal\"\u003erandom_zipfian\u003c/code\u003e or \u003ccode class=\"literal\"\u003erandom_exponential\u003c/code\u003e so that values drawn more often are not trivially correlated. For instance, the following \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e script simulates a possible real world workload typical for social media and blogging platforms where a few accounts generate excessive load:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set size 1000000\n\\set r random_zipfian(1, :size, 1.07)\n\\set k 1 + permute(:r, :size)\n\u003c/pre\u003e\n\u003cp\u003eIn some cases several distinct distributions are needed which don't correlate with each other and this is when the optional seed parameter comes in handy:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set k1 1 + permute(:r, :size, :default_seed + 123)\n\\set k2 1 + permute(:r, :size, :default_seed + 321)\n\u003c/pre\u003e\n\u003cp\u003eA similar behavior can also be approximated with \u003ccode class=\"function\"\u003ehash\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set size 1000000\n\\set r random_zipfian(1, 100 * :size, 1.07)\n\\set k 1 + abs(hash(:r)) % :size\n\u003c/pre\u003e\n\u003cp\u003eHowever, since \u003ccode class=\"function\"\u003ehash\u003c/code\u003e generates collisions, some values will not be reachable and others will be more frequent than expected from the original distribution.\u003c/p\u003e\n\u003cp\u003eAs an example, the full definition of the built-in TPC-B-like transaction is:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set aid random(1, 100000 * :scale)\n\\set bid random(1, 1 * :scale)\n\\set tid random(1, 10 * :scale)\n\\set delta random(-5000, 5000)\nBEGIN;\nUPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\nSELECT abalance FROM pgbench_accounts WHERE aid = :aid;\nUPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\nUPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\nINSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\nEND;\n\u003c/pre\u003e\n\u003cp\u003eThis 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 — otherwise they'd not be independently touching different rows.)\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.6\"\u003e\n\u003ch3\u003ePer-Transaction Logging\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode class=\"option\"\u003e-l\u003c/code\u003e option (but without the \u003ccode class=\"option\"\u003e--aggregate-interval\u003c/code\u003e option), \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e writes information about each transaction to a log file. The log file will be named \u003ccode class=\"filename\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e defaults to \u003ccode class=\"literal\"\u003epgbench_log\u003c/code\u003e, and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e is the PID of the \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e process. The prefix can be changed by using the \u003ccode class=\"option\"\u003e--log-prefix\u003c/code\u003e option. If the \u003ccode class=\"option\"\u003e-j\u003c/code\u003e option is 2 or higher, so that there are multiple worker threads, each will have its own log file. The first worker will use the same name for its log file as in the standard single worker case. The additional log files for the other workers will be named \u003ccode class=\"filename\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003ennn\u003c/code\u003e\u003c/em\u003e.\u003cem class=\"replaceable\"\u003e\u003ccode\u003emmm\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003emmm\u003c/code\u003e\u003c/em\u003e is a sequential number for each worker starting with 1.\u003c/p\u003e\n\u003cp\u003eEach line in a log file describes one transaction. It contains the following space-separated fields:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eclient_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eidentifies the client session that ran the transaction\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_no\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ecounts how many transactions have been run by that session\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction's elapsed time, in microseconds\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003escript_no\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eidentifies the script file that was used for the transaction (useful when multiple scripts are specified with \u003ccode class=\"option\"\u003e-f\u003c/code\u003e or \u003ccode class=\"option\"\u003e-b\u003c/code\u003e)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etime_epoch\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction's completion time, as a Unix-epoch time stamp\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etime_us\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003efractional-second part of transaction's completion time, in microseconds\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschedule_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003etransaction start delay, that is the difference between the transaction's scheduled start time and the time it actually started, in microseconds (present only if \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ecount of retries after serialization or deadlock errors during the transaction (present only if \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eWhen both \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e and \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e are used, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e for a skipped transaction will be reported as \u003ccode class=\"literal\"\u003eskipped\u003c/code\u003e. If the transaction ends with a failure, its \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e will be reported as \u003ccode class=\"literal\"\u003efailed\u003c/code\u003e. If you use the \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e option, the \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e of the failed transaction will be reported as \u003ccode class=\"literal\"\u003eserialization\u003c/code\u003e or \u003ccode class=\"literal\"\u003edeadlock\u003c/code\u003e depending on the type of failure (see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information).\u003c/p\u003e\n\u003cp\u003eHere is a snippet of a log file generated in a single-client run:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e0 199 2241 0 1175850568 995598\n0 200 2465 0 1175850568 998079\n0 201 2513 0 1175850569 608\n0 202 2038 0 1175850569 2663\n\u003c/pre\u003e\n\u003cp\u003eAnother example with \u003ccode class=\"literal\"\u003e--rate=100\u003c/code\u003e and \u003ccode class=\"literal\"\u003e--latency-limit=5\u003c/code\u003e (note the additional \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschedule_lag\u003c/code\u003e\u003c/em\u003e column):\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e0 81 4621 0 1412881037 912698 3005\n0 82 6173 0 1412881037 914578 4304\n0 83 skipped 0 1412881037 914578 5217\n0 83 skipped 0 1412881037 914578 5099\n0 83 4722 0 1412881037 916203 3108\n0 84 4142 0 1412881037 918023 2333\n0 85 2465 0 1412881037 919759 740\n\u003c/pre\u003e\n\u003cp\u003eIn this example, transaction 82 was late, because its latency (6.173 ms) was over the 5 ms limit. The next two transactions were skipped, because they were already late before they were even started.\u003c/p\u003e\n\u003cp\u003eThe following example shows a snippet of a log file with failures and retries, with the maximum number of tries set to 10 (note the additional \u003cem class=\"replaceable\"\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e column):\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e3 0 47423 0 1499414498 34501 3\n3 1 8333 0 1499414498 42848 0\n3 2 8358 0 1499414498 51219 0\n4 0 72345 0 1499414498 59433 6\n1 3 41718 0 1499414498 67879 4\n1 4 8416 0 1499414498 76311 0\n3 3 33235 0 1499414498 84469 3\n0 0 failed 0 1499414498 84905 9\n2 0 failed 0 1499414498 86248 9\n3 4 8307 0 1499414498 92788 0\n\u003c/pre\u003e\n\u003cp\u003eIf the \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e option is used, the type of failure is reported in the \u003cem class=\"replaceable\"\u003e\u003ccode\u003etime\u003c/code\u003e\u003c/em\u003e like this:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e3 0 47423 0 1499414498 34501 3\n3 1 8333 0 1499414498 42848 0\n3 2 8358 0 1499414498 51219 0\n4 0 72345 0 1499414498 59433 6\n1 3 41718 0 1499414498 67879 4\n1 4 8416 0 1499414498 76311 0\n3 3 33235 0 1499414498 84469 3\n0 0 serialization 0 1499414498 84905 9\n2 0 serialization 0 1499414498 86248 9\n3 4 8307 0 1499414498 92788 0\n\u003c/pre\u003e\n\u003cp\u003eWhen running a long test on hardware that can handle a lot of transactions, the log files can become very large. The \u003ccode class=\"option\"\u003e--sampling-rate\u003c/code\u003e option can be used to log only a random sample of transactions.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.7\"\u003e\n\u003ch3\u003eAggregated Logging\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode class=\"option\"\u003e--aggregate-interval\u003c/code\u003e option, a different format is used for the log files. Each log line describes one aggregation interval. It contains the following space-separated fields:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval_start\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003estart time of the interval, as a Unix-epoch time stamp\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003enum_transactions\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions within the interval\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of transaction latencies\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_latency_2\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of squares of transaction latencies\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emin_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eminimum transaction latency\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emax_latency\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003emaximum transaction latency\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of transaction start delays (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003esum_lag_2\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003esum of squares of transaction start delays (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emin_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eminimum transaction start delay (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003emax_lag\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003emaximum transaction start delay (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eskipped\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions skipped because they would have started too late (zero unless \u003ccode class=\"option\"\u003e--rate\u003c/code\u003e and \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e are specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eretried\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of retried transactions (zero unless \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eretries\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of retries after serialization or deadlock errors (zero unless \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e is not equal to one)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eserialization_failures\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions that got a serialization error and were not retried afterwards (zero unless \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edeadlock_failures\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003enumber of transactions that got a deadlock error and were not retried afterwards (zero unless \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e is specified)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eHere is some example output generated with this option:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003cstrong class=\"userinput\"\u003e\u003ccode\u003epgbench --aggregate-interval=10 --time=20 --client=10 --log --rate=1000 --latency-limit=10 --failures-detailed --max-tries=10 test\u003c/code\u003e\u003c/strong\u003e\n\n1650260552 5178 26171317 177284491527 1136 44462 2647617 7321113867 0 9866 64 7564 28340 4148 0\n1650260562 4808 25573984 220121792172 1171 62083 3037380 9666800914 0 9998 598 7392 26621 4527 0\n\u003c/pre\u003e\n\u003cp\u003eNotice that while the plain (unaggregated) log format shows which script was used for each transaction, the aggregated format does not. Therefore if you need per-script data, you need to aggregate the data on your own.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.8\"\u003e\n\u003ch3\u003ePer-Statement Report\u003c/h3\u003e\n\u003cp\u003eWith the \u003ccode class=\"option\"\u003e-r\u003c/code\u003e option, \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e collects the following statistics for each statement:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003elatency\u003c/code\u003e — elapsed transaction time for each statement. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e reports an average value of all successful runs of the statement.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eThe number of failures in this statement. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eThe number of retries after a serialization or a deadlock error in this statement. See \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#FAILURES-AND-RETRIES\" title=\"Failures and Serialization/Deadlock Retries\"\u003eFailures and Serialization/Deadlock Retries\u003c/a\u003e for more information.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eThe report displays retry statistics only if the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003cp\u003eAll values are computed for each statement executed by every client and are reported after the benchmark has finished.\u003c/p\u003e\n\u003cp\u003eFor the default script, the output will look similar to this:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003estarting vacuum...end.\ntransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 1\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000/10000\nnumber of failed transactions: 0 (0.000%)\nnumber of transactions above the 50.0 ms latency limit: 1311/10000 (13.110 %)\nlatency average = 28.488 ms\nlatency stddev = 21.009 ms\ninitial connection time = 69.068 ms\ntps = 346.224794 (without initial connection time)\nstatement latencies in milliseconds and failures:\n   0.012  0  \\set aid random(1, 100000 * :scale)\n   0.002  0  \\set bid random(1, 1 * :scale)\n   0.002  0  \\set tid random(1, 10 * :scale)\n   0.002  0  \\set delta random(-5000, 5000)\n   0.319  0  BEGIN;\n   0.834  0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n   0.641  0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n  11.126  0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n  12.961  0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n   0.634  0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n   1.957  0  END;\n\u003c/pre\u003e\n\u003cp\u003eAnother example of output for the default script using serializable default transaction isolation level (\u003ccode class=\"command\"\u003ePGOPTIONS='-c default_transaction_isolation=serializable' pgbench ...\u003c/code\u003e):\u003c/p\u003e\n\u003cpre class=\"screen\"\u003estarting vacuum...end.\ntransaction type: \u0026lt;builtin: TPC-B (sort of)\u0026gt;\nscaling factor: 1\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nmaximum number of tries: 10\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 6317/10000\nnumber of failed transactions: 3683 (36.830%)\nnumber of transactions retried: 7667 (76.670%)\ntotal number of retries: 45339\nnumber of transactions above the 50.0 ms latency limit: 106/6317 (1.678 %)\nlatency average = 17.016 ms\nlatency stddev = 13.283 ms\ninitial connection time = 45.017 ms\ntps = 186.792667 (without initial connection time)\nstatement latencies in milliseconds, failures and retries:\n  0.006     0      0  \\set aid random(1, 100000 * :scale)\n  0.001     0      0  \\set bid random(1, 1 * :scale)\n  0.001     0      0  \\set tid random(1, 10 * :scale)\n  0.001     0      0  \\set delta random(-5000, 5000)\n  0.385     0      0  BEGIN;\n  0.773     0      1  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n  0.624     0      0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n  1.098   320   3762  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n  0.582  3363  41576  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n  0.465     0      0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n  1.933     0      0  END;\n\u003c/pre\u003e\n\u003cp\u003eIf multiple script files are specified, all statistics are reported separately for each script file.\u003c/p\u003e\n\u003cp\u003eNote that collecting the additional timing information needed for per-statement latency computation adds some overhead. This will slow average execution speed and lower the computed TPS. The amount of slowdown varies significantly depending on platform and hardware. Comparing average TPS values with and without latency reporting enabled is a good way to measure if the timing overhead is significant.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"FAILURES-AND-RETRIES\"\u003e\n\u003ch3\u003eFailures and Serialization/Deadlock Retries\u003c/h3\u003e\n\u003cp\u003eWhen executing \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e, there are three main types of errors:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eErrors of the main program. They are the most serious and always result in an immediate exit from \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e with the corresponding error message. They include:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eerrors at the beginning of \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e (e.g. an invalid option value);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eerrors in the initialization mode (e.g. the query to create tables for built-in scripts fails);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eerrors before starting threads (e.g. could not connect to the database server, syntax error in the meta command, thread creation failure);\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003einternal \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e errors (which are supposed to never occur...).\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eErrors when the thread manages its clients (e.g. the client could not start a connection to the database server / the socket for connecting the client to the database server has become invalid). In such cases all clients of this thread stop while other threads continue to work. However, \u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e is specified, all of the threads stop immediately in this case.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eDirect client errors. They lead to immediate exit from \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e with the corresponding error message in the case of an internal \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e error (which are supposed to never occur...) or when \u003ccode class=\"option\"\u003e--exit-on-abort\u003c/code\u003e is specified. Otherwise in the worst case they only lead to the abortion of the failed client while other clients continue their run (but some client errors are handled without an abortion of the client and reported separately, see below). Later in this section it is assumed that the discussed errors are only the direct client errors and they are not internal \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e errors.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eA client's run is aborted in case of a serious error; for example, the connection with the database server was lost or the end of script was reached without completing the last transaction. In addition, if execution of an SQL or meta command fails for reasons other than serialization or deadlock errors, the client is aborted. Otherwise, if an SQL command fails with serialization or deadlock errors, the client is not aborted. In such cases, the current transaction is rolled back, which also includes setting the client variables as they were before the run of this transaction (it is assumed that one transaction script contains only one transaction; see \u003ca class=\"xref\" href=\"/docs/18/pgbench.html#TRANSACTIONS-AND-SCRIPTS\" title=\"What Is the “Transaction” Actually Performed in pgbench?\"\u003eWhat Is the \"Transaction\" Actually Performed in pgbench?\u003c/a\u003e for more information). Transactions with serialization or deadlock errors are repeated after rollbacks until they complete successfully or reach the maximum number of tries (specified by the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option) / the maximum time of retries (specified by the \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e option) / the end of benchmark (specified by the \u003ccode class=\"option\"\u003e--time\u003c/code\u003e option). If the last trial run fails, this transaction will be reported as failed but the client is not aborted and continues to work.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWithout specifying the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option, a transaction will never be retried after a serialization or deadlock error because its default value is 1. Use an unlimited number of tries (\u003ccode class=\"literal\"\u003e--max-tries=0\u003c/code\u003e) and the \u003ccode class=\"option\"\u003e--latency-limit\u003c/code\u003e option to limit only the maximum time of tries. You can also use the \u003ccode class=\"option\"\u003e--time\u003c/code\u003e option to limit the benchmark duration under an unlimited number of tries.\u003c/p\u003e\n\u003cp\u003eBe careful when repeating scripts that contain multiple transactions: the script is always retried completely, so successful transactions can be performed several times.\u003c/p\u003e\n\u003cp\u003eBe careful when repeating transactions with shell commands. Unlike the results of SQL commands, the results of shell commands are not rolled back, except for the variable value of the \u003ccode class=\"command\"\u003e\\setshell\u003c/code\u003e command.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eThe latency of a successful transaction includes the entire time of transaction execution with rollbacks and retries. The latency is measured only for successful transactions and commands but not for failed transactions or commands.\u003c/p\u003e\n\u003cp\u003eThe main report contains the number of failed transactions. If the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1, the main report also contains statistics related to retries: the total number of retried transactions and total number of retries. The per-script report inherits all these fields from the main report. The per-statement report displays retry statistics only if the \u003ccode class=\"option\"\u003e--max-tries\u003c/code\u003e option is not equal to 1.\u003c/p\u003e\n\u003cp\u003eIf you want to group failures by basic types in per-transaction and aggregation logs, as well as in the main and per-script reports, use the \u003ccode class=\"option\"\u003e--failures-detailed\u003c/code\u003e option. If you also want to distinguish all errors and failures (errors without retrying) by type including which limit for retries was exceeded and how much it was exceeded by for the serialization/deadlock failures, use the \u003ccode class=\"option\"\u003e--verbose-errors\u003c/code\u003e option.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.10\"\u003e\n\u003ch3\u003eTable Access Methods\u003c/h3\u003e\n\u003cp\u003eYou may specify the \u003ca class=\"link\" href=\"/docs/18/tableam.html\" title=\"Chapter 62. Table Access Method Interface Definition\"\u003eTable Access Method\u003c/a\u003e for the pgbench tables. The environment variable \u003ccode class=\"envar\"\u003ePGOPTIONS\u003c/code\u003e specifies database configuration options that are passed to PostgreSQL via the command line (See \u003ca class=\"xref\" href=\"/docs/18/config-setting.html#CONFIG-SETTING-SHELL\" title=\"19.1.4. Parameter Interaction via the Shell\"\u003eSection 19.1.4\u003c/a\u003e). For example, a hypothetical default Table Access Method for the tables that pgbench creates called \u003ccode class=\"literal\"\u003ewuzza\u003c/code\u003e can be specified with:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003ePGOPTIONS='-c default_table_access_method=wuzza'\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.11\"\u003e\n\u003ch3\u003eGood Practices\u003c/h3\u003e\n\u003cp\u003eIt is very easy to use \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e to produce completely meaningless numbers. Here are some guidelines to help you get useful results.\u003c/p\u003e\n\u003cp\u003eIn the first place, \u003cspan class=\"emphasis\"\u003e\u003cem\u003enever\u003c/em\u003e\u003c/span\u003e believe any test that runs for only a few seconds. Use the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e option 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.\u003c/p\u003e\n\u003cp\u003eFor the default TPC-B-like test scenario, the initialization scale factor (\u003ccode class=\"option\"\u003e-s\u003c/code\u003e) should be at least as large as the largest number of clients you intend to test (\u003ccode class=\"option\"\u003e-c\u003c/code\u003e); else you'll mostly be measuring update contention. There are only \u003ccode class=\"option\"\u003e-s\u003c/code\u003e rows in the \u003ccode class=\"structname\"\u003epgbench_branches\u003c/code\u003e table, and every transaction wants to update one of them, so \u003ccode class=\"option\"\u003e-c\u003c/code\u003e values in excess of \u003ccode class=\"option\"\u003e-s\u003c/code\u003e will undoubtedly result in lots of transactions blocked waiting for other transactions.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003cp\u003eA limitation of \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e is that it can itself become the bottleneck when trying to test a large number of client sessions. This can be alleviated by running \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e on a different machine from the database server, although low network latency will be essential. It might even be useful to run several \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e instances concurrently, on several client machines, against the same database server.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.11.9.12\"\u003e\n\u003ch3\u003eSecurity\u003c/h3\u003e\n\u003cp\u003eIf untrusted users have access to a database that has not adopted a \u003ca class=\"link\" href=\"/docs/18/ddl-schemas.html#DDL-SCHEMAS-PATTERNS\" title=\"5.10.6. Usage Patterns\"\u003esecure schema usage pattern\u003c/a\u003e, do not run \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e in that database. \u003cspan class=\"application\"\u003epgbench\u003c/span\u003e uses unqualified names and does not manipulate the search path.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-i --initialize","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INITIALIZE"},"summary":"Required to invoke initialization mode."},{"signature":{"text":"-I init_steps --init-steps= init_steps","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INIT-STEPS"},"summary":"Perform just a selected set of the normal initialization steps. init_steps specifies the initialization steps to be performed, using one character per step. Each step is invoked in the specified order. The default is dtgvp . The available steps are:"},{"signature":{"text":"-F fillfactor --fillfactor= fillfactor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILLFACTOR"},"summary":"Create the pgbench_accounts , pgbench_tellers and pgbench_branches tables with the given fillfactor. Default is 100."},{"signature":{"text":"-n --no-vacuum","url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-INIT"},"summary":"Perform no vacuuming during initialization. (This option suppresses the v initialization step, even if it was specified in -I .)"},{"signature":{"text":"-q --quiet","url":"/docs/18/pgbench.html#PGBENCH-OPTION-QUIET"},"summary":"Switch logging to quiet mode, producing only one progress message per 5 seconds. The default logging prints one message each 100,000 rows, which often outputs many lines per second (especially on good hardware)."},{"signature":{"text":"-s scale_factor --scale= scale_factor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-INIT"},"summary":"Multiply the number of rows generated by the scale factor. For example, -s 100 will create 10,000,000 rows in the pgbench_accounts table. Default is 1. When the scale is 20,000 or larger, the columns used to hold account identifiers ( aid columns) will switch to using larger integers ( bigint ), in order to be big enough to hold the range of account identifiers."},{"signature":{"text":"--foreign-keys","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FOREIGN-KEYS"},"summary":"Create foreign key constraints between the standard tables. (This option adds the f step to the initialization step sequence, if it is not already present.)"},{"signature":{"text":"--index-tablespace= index_tablespace","url":"/docs/18/pgbench.html#PGBENCH-OPTION-INDEX-TABLESPACE"},"summary":"Create indexes in the specified tablespace, rather than the default tablespace."},{"signature":{"text":"--partition-method= NAME","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITION-METHOD"},"summary":"Create a partitioned pgbench_accounts table with NAME method. Expected values are range or hash . This option requires that --partitions is set to non-zero. If unspecified, default is range ."},{"signature":{"text":"--partitions= NUM","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PARTITIONS"},"summary":"Create a partitioned pgbench_accounts table with NUM partitions of nearly equal size for the scaled number of accounts. Default is 0 , meaning no partitioning."},{"signature":{"text":"--tablespace= tablespace","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TABLESPACE"},"summary":"Create tables in the specified tablespace, rather than the default tablespace."},{"signature":{"text":"--unlogged-tables","url":"/docs/18/pgbench.html#PGBENCH-OPTION-UNLOGGED-TABLES"},"summary":"Create all tables as unlogged tables, rather than permanent tables."},{"signature":{"text":"-b scriptname[@weight] --builtin = scriptname[@weight]","url":"/docs/18/pgbench.html#PGBENCH-OPTION-BUILTIN"},"summary":"Add the specified built-in script to the list of scripts to be executed. Available built-in scripts are: tpcb-like , simple-update and select-only . Unambiguous prefixes of built-in names are accepted. With the special name list , show the list of built-in scripts and exit immediately."},{"signature":{"text":"-c clients --client= clients","url":"/docs/18/pgbench.html#PGBENCH-OPTION-CLIENT"},"summary":"Number of clients simulated, that is, number of concurrent database sessions. Default is 1."},{"signature":{"text":"-C --connect","url":"/docs/18/pgbench.html#PGBENCH-OPTION-CONNECT"},"summary":"Establish a new connection for each transaction, rather than doing it just once per client session. This is useful to measure the connection overhead."},{"signature":{"text":"-D varname = value --define= varname = value","url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEFINE"},"summary":"Define a variable for use by a custom script (see below). Multiple -D options are allowed."},{"signature":{"text":"-f filename[@weight] --file= filename[@weight]","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FILE"},"summary":"Add a transaction script read from filename to the list of scripts to be executed."},{"signature":{"text":"-j threads --jobs= threads","url":"/docs/18/pgbench.html#PGBENCH-OPTION-JOBS"},"summary":"Number of worker threads within pgbench . Using more than one thread can be helpful on multi-CPU machines. Clients are distributed as evenly as possible among available threads. Default is 1."},{"signature":{"text":"-l --log","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG"},"summary":"Write information about each transaction to a log file. See below for details."},{"signature":{"text":"-L limit --latency-limit= limit","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LATENCY-LIMIT"},"summary":"Transactions that last more than limit milliseconds are counted and reported separately, as late ."},{"signature":{"text":"-M querymode --protocol= querymode","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROTOCOL"},"summary":"Protocol to use for submitting queries to the server:"},{"signature":{"text":"-n --no-vacuum","url":"/docs/18/pgbench.html#PGBENCH-OPTION-NO-VACUUM-RUN"},"summary":"Perform no vacuuming before running the test. This option is necessary if you are running a custom test scenario that does not include the standard tables pgbench_accounts , pgbench_branches , pgbench_history , and pgbench_tellers ."},{"signature":{"text":"-N --skip-some-updates","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SKIP-SOME-UPDATES"},"summary":"Run built-in simple-update script. Shorthand for -b simple-update ."},{"signature":{"text":"-P sec --progress= sec","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS"},"summary":"Show progress report every sec seconds. The report includes the time since the beginning of the run, the TPS since the last report, and the transaction latency average, standard deviation, and the number of failed transactions since the last report. Under throttling ( -R ), the latency is computed with respect to the transaction scheduled start time, not the actual transaction beginning time, thus it also includes the average schedule lag time. When --max-tries is used to enable transaction retries after serialization/deadlock errors, the report includes the number of retried transactions and the sum of all retries."},{"signature":{"text":"-r --report-per-command","url":"/docs/18/pgbench.html#PGBENCH-OPTION-REPORT-LATENCIES"},"summary":"Report the following statistics for each command after the benchmark finishes: the average per-statement latency (execution time from the perspective of the client), the number of failures, and the number of retries after serialization or deadlock errors in this command. The report displays retry statistics only if the --max-tries option is not equal to 1."},{"signature":{"text":"-R rate --rate= rate","url":"/docs/18/pgbench.html#PGBENCH-OPTION-RATE"},"summary":"Execute transactions targeting the specified rate instead of running as fast as possible (the default). The rate is given in transactions per second. If the targeted rate is above the maximum possible rate, the rate limit won't impact the results."},{"signature":{"text":"-s scale_factor --scale= scale_factor","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SCALE-RUN"},"summary":"Report the specified scale factor in pgbench '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 pgbench_branches table. However, when testing only custom benchmarks ( -f option), the scale factor will be reported as 1 unless this option is used."},{"signature":{"text":"-S --select-only","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SELECT-ONLY"},"summary":"Run built-in select-only script. Shorthand for -b select-only ."},{"signature":{"text":"-t transactions --transactions= transactions","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TRANSACTIONS"},"summary":"Number of transactions each client runs. Default is 10."},{"signature":{"text":"-T seconds --time= seconds","url":"/docs/18/pgbench.html#PGBENCH-OPTION-TIME"},"summary":"Run the test for this many seconds, rather than a fixed number of transactions per client. -t and -T are mutually exclusive."},{"signature":{"text":"-v --vacuum-all","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VACUUM-ALL"},"summary":"Vacuum all four standard tables before running the test. With neither -n nor -v , pgbench will vacuum the pgbench_tellers and pgbench_branches tables, and will truncate pgbench_history ."},{"signature":{"text":"--aggregate-interval= seconds","url":"/docs/18/pgbench.html#PGBENCH-OPTION-AGGREGATE-INTERVAL"},"summary":"Length of aggregation interval (in seconds). May be used only with -l option. With this option, the log contains per-interval summary data, as described below."},{"signature":{"text":"--exit-on-abort","url":"/docs/18/pgbench.html#PGBENCH-OPTION-EXIT-ON-ABORT"},"summary":"Exit immediately when any client is aborted due to some error. Without this option, even when a client is aborted, other clients could continue their run as specified by -t or -T option, and pgbench will print an incomplete results in this case."},{"signature":{"text":"--failures-detailed","url":"/docs/18/pgbench.html#PGBENCH-OPTION-FAILURES-DETAILED"},"summary":"Report failures in per-transaction and aggregation logs, as well as in the main and per-script reports, grouped by the following types:"},{"signature":{"text":"--log-prefix= prefix","url":"/docs/18/pgbench.html#PGBENCH-OPTION-LOG-PREFIX"},"summary":"Set the filename prefix for the log files created by --log . The default is pgbench_log ."},{"signature":{"text":"--max-tries= number_of_tries","url":"/docs/18/pgbench.html#PGBENCH-OPTION-MAX-TRIES"},"summary":"Enable retries for transactions with serialization/deadlock errors and set the maximum number of these tries. This option can be combined with the --latency-limit option which limits the total time of all transaction tries; moreover, you cannot use an unlimited number of tries ( --max-tries=0 ) without --latency-limit or --time . The default value is 1 and transactions with serialization/deadlock errors are not retried. See Failures and Serialization/Deadlock Retries for more information about retrying such transactions."},{"signature":{"text":"--progress-timestamp","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PROGRESS-TIMESTAMP"},"summary":"When showing progress (option -P ), use a timestamp (Unix epoch) instead of the number of seconds since the beginning of the run. The unit is in seconds, with millisecond precision after the dot. This helps compare logs generated by various tools."},{"signature":{"text":"--random-seed= seed","url":"/docs/18/pgbench.html#PGBENCH-OPTION-RANDOM-SEED"},"summary":"Set random generator seed. Seeds the system random number generator, which then produces a sequence of initial generator states, one for each thread. Values for seed may be: time (the default, the seed is based on the current time), rand (use a strong random source, failing if none is available), or an unsigned decimal integer value. The random generator is invoked explicitly from a pgbench script ( random... functions) or implicitly (for instance option --rate uses it to schedule transactions). When explicitly set, the value used for seeding is shown on the terminal. Any value allowed for seed may also be provided through the environment variable PGBENCH_RANDOM_SEED . To ensure that the provided seed impacts all possible uses, put this option first or use the environment variable."},{"signature":{"text":"--sampling-rate= rate","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SAMPLING-RATE"},"summary":"Sampling rate, used when writing data into the log, to reduce the amount of log generated. If this option is given, only the specified fraction of transactions are logged. 1.0 means all transactions will be logged, 0.05 means only 5% of the transactions will be logged."},{"signature":{"text":"--show-script= scriptname","url":"/docs/18/pgbench.html#PGBENCH-OPTION-SHOW-SCRIPT"},"summary":"Show the actual code of builtin script scriptname on stderr, and exit immediately."},{"signature":{"text":"--verbose-errors","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERBOSE-ERRORS"},"summary":"Print messages about all errors and failures (errors without retrying) including which limit for retries was exceeded and how far it was exceeded for the serialization/deadlock failures. (Note that in this case the output can be significantly increased.) See Failures and Serialization/Deadlock Retries for more information."},{"signature":{"text":"--debug","url":"/docs/18/pgbench.html#PGBENCH-OPTION-DEBUG"},"summary":"Print debugging output."},{"signature":{"text":"-h hostname --host= hostname","url":"/docs/18/pgbench.html#PGBENCH-OPTION-HOST"},"summary":"The database server's host name"},{"signature":{"text":"-p port --port= port","url":"/docs/18/pgbench.html#PGBENCH-OPTION-PORT"},"summary":"The database server's port number"},{"signature":{"text":"-U login --username= login","url":"/docs/18/pgbench.html#PGBENCH-OPTION-USERNAME"},"summary":"The user name to connect as"},{"signature":{"text":"-V --version","url":"/docs/18/pgbench.html#PGBENCH-OPTION-VERSION"},"summary":"Print the pgbench version and exit."},{"signature":{"text":"-? --help","url":"/docs/18/pgbench.html#PGBENCH-OPTION-HELP"},"summary":"Show help about pgbench command line arguments, and exit."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Default connection parameters.","name":"PGDATABASE PGHOST PGPORT PGUSER"}],"title":"Environment variables"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
