diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
new file mode 100644
index 03e1212..a51c014
*** a/doc/src/sgml/ref/pgbench.sgml
--- b/doc/src/sgml/ref/pgbench.sgml
*************** pgbench <optional> <replaceable>options<
*** 269,275 ****
          Add the specified built-in script to the list of executed scripts.
          An optional integer weight after <literal>@</> allows to adjust the
          probability of drawing the script.  If not specified, it is set to 1.
!         Available built-in scripts are: <literal>tpcb-like</>,
          <literal>simple-update</> and <literal>select-only</>.
          Unambiguous prefixes of built-in names are accepted.
          With special name <literal>list</>, show the list of built-in scripts
--- 269,275 ----
          Add the specified built-in script to the list of executed scripts.
          An optional integer weight after <literal>@</> allows to adjust the
          probability of drawing the script.  If not specified, it is set to 1.
!         Available built-in scripts are: <literal>tpcb-like</>, <literal>tpcb-func</>,
          <literal>simple-update</> and <literal>select-only</>.
          Unambiguous prefixes of built-in names are accepted.
          With special name <literal>list</>, show the list of built-in scripts
*************** pgbench <optional> <replaceable>options<
*** 726,731 ****
--- 726,737 ----
    </orderedlist>
  
    <para>
+    If you select the <literal>tpcb-func</> built-in,
+    the above steps are carried out by a single call to a <application>PL/pgSQL</> function,
+    reducing the overhead from inter-process-communication.
+   </para>
+ 
+   <para>
     If you select the <literal>simple-update</> built-in (also <option>-N</>),
     steps 4 and 5 aren't included in the transaction.
     This will avoid update contention on these tables, but
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
new file mode 100644
index ae78c7b..00e82ef
*** a/src/bin/pgbench/pgbench.c
--- b/src/bin/pgbench/pgbench.c
*************** static const BuiltinScript builtin_scrip
*** 425,430 ****
--- 425,439 ----
  		"END;\n"
  	},
  	{
+ 		"tpcb-func",
+ 		"<builtin: TPC-B (sort of) in PL/pgSQL>",
+ 		"\\set aid random(1, " CppAsString2(naccounts) " * :scale)\n"
+ 		"\\set bid random(1, " CppAsString2(nbranches) " * :scale)\n"
+ 		"\\set tid random(1, " CppAsString2(ntellers) " * :scale)\n"
+ 		"\\set delta random(-5000, 5000)\n"
+ 		"select * from pgbench_transaction(:aid, :bid, :tid, :delta);\n"
+ 	},
+ 	{
  		"simple-update",
  		"<builtin: simple update>",
  		"\\set aid random(1, " CppAsString2(naccounts) " * :scale)\n"
*************** init(bool is_no_vacuum)
*** 2688,2693 ****
--- 2697,2716 ----
  		executeStatement(con, buffer);
  	}
  
+ 	executeStatement(con, 
+ 		"create or replace function pgbench_transaction(arg_aid int, arg_bid int, arg_tid int, arg_delta int) returns int as $$"
+ 		"DECLARE\n"
+ 		"abal int;\n"
+ 		"BEGIN\n"
+ 		"UPDATE pgbench_accounts SET abalance = abalance + arg_delta WHERE aid = arg_aid;\n"
+ 		"SELECT abalance into abal FROM pgbench_accounts WHERE aid = arg_aid;\n"
+ 		"UPDATE pgbench_tellers SET tbalance = tbalance + arg_delta WHERE tid = arg_tid;\n"
+ 		"UPDATE pgbench_branches SET bbalance = bbalance + arg_delta WHERE bid = arg_bid;\n"
+ 		"INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (arg_tid, arg_bid, arg_aid, arg_delta, CURRENT_TIMESTAMP);\n"
+ 		"RETURN abal;\n"
+ 		"END;\n"
+ 		"$$ language plpgsql");
+ 
  	executeStatement(con, "begin");
  
  	for (i = 0; i < nbranches * scale; i++)
