sneawo
sneawo

Reputation: 3631

Why psql is slow?

I have a file with a simple query SELECT 1; repeated 1000 times. When I run it through time psql -f test.sql -o /dev/null/, there are next results:

real    0m0.362s
user    0m0.064s
sys     0m0.060s

It's about 1000/0.362 = 2762 queries/sec?

In pgbench for this query I have:

transaction type: Custom query
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
number of transactions per client: 100000
number of transactions actually processed: 100000/100000
tps = 12233.355663 (including connections establishing)
tps = 12239.560512 (excluding connections establishing)

Where psql spends time?

Upvotes: 0

Views: 352

Answers (1)

Pavel Stehule
Pavel Stehule

Reputation: 45750

psql is simply and generic software and fact so output is /dev/null doesn't ensure disabling of formatted output generating. And parsing of generic lines needs some time too. For very simple and very fast queries this overhead can be significant.

Upvotes: 1

Related Questions