{"Entry":{"collection":"tool","key":"pgbench","name":"pgbench","aliases":["pgbench"],"metadata":{"aliases":["pgbench"],"category":"Client applications","content_hash":"94a6876ee565cdc95e5811669e9a04b670679beb44ee0376d7af1ce2251784b7","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"],"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"}],"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":[],"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"}]},"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":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
