begin transaction SELECT nextval('seq_order_id') as orderId SELECT * FROM orders WHERE accountid = ? AND status IN (3, 7) INSERT INTO orders (orderid, ... ) end transaction g_benchmark=# explain analyze select * from orders where accountid=1000001 and status IN (3,7); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------- Index Scan using index_orders_accountid on orders (cost=0.00..9.37 rows=1 width=250) (actual time=3.179..3.179 rows=0 loops=1) Index Cond: (accountid = 1000001) Filter: ((status = 3) OR (status = 7)) Total runtime: 3.254 ms (4 rows) ------------------- Runtimes Each run time figure is the time to complete the the above transaction for the number of specified times (serially - one after another)' 1: elapsed time: 0.032 sec 100: elapsed time: 1.643 sec 1000: elapsed time: 16.441 sec