How to check the number of queries per second (QPS) on the PostgreSQL DB instance?
Dmitry Romanoff
Posted on November 15, 2023
To check the number of queries per second (QPS) on the PostgreSQL DB instance run the following SQL query:
with
t1 as (select sum(calls) n from pg_stat_statements),
t2 as (select sum(calls) n from pg_stat_statements , pg_sleep(1))
select
t2.n-t1.n the_num_of_queries_per_second
from
t1,t2;
Example:
postgres=> with
postgres-> t1 as (select sum(calls) n from pg_stat_statements),
postgres-> t2 as (select sum(calls) n from pg_stat_statements , pg_sleep(1))
postgres-> select
postgres-> t2.n-t1.n the_num_of_queries_per_second
postgres-> from
postgres-> t1,t2;
the_num_of_queries_per_second
-------------------------------
1234
(1 row)
postgres=>
ask_dima@yahoo.com
💖 💪 🙅 🚩
Dmitry Romanoff
Posted on November 15, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
postgres How to check the number of queries per second (QPS) on the PostgreSQL DB instance?
November 15, 2023