require 'postgres' pids = [] threshold = ARGV[0]; offset = ARGV[1]; sql = " SET trace_sync_seqscan=true; SET sync_seqscan_threshold=#{threshold}; SET sync_seqscan_offset=#{offset}; SELECT COUNT(*) FROM bigtable; " def getconn() PGconn.connect('/tmp',nil,nil,nil,'db02','jdavis',nil) end for i in 0..4 do pids << fork { db = getconn sleep i*30 + 1 db.exec sql } end pids.each{ |pid| Process.waitpid pid }