February 2020
Intermediate to advanced
734 pages
38h 13m
English
We can collect some of the information we want from the database if we have one already. If we already have a PostgreSQL database available, we can execute a query to start our calculations. This works best if used at the most active time of day.
If you have PostgreSQL 9.2 or higher, execute this query as a superuser to get the count of simultaneous active users:
SELECT count(*) FROM pg_stat_activity WHERE state = 'active';
Use this query if you have an older version:
SELECT count(*) FROM pg_stat_activity WHERE current_query NOT LIKE '<IDLE>%';
If we don't have a PostgreSQL server, we need to make an educated guess. Use these steps to approximate:
Read now
Unlock full access