how to interpret stddev_time and hit_percent

1.3k Views Asked by At

I launched the following command, showed in this documentation: https://www.postgresql.org/docs/current/pgstatstatements.html

SELECT query, 
       calls, 
       total_time, 
       rows, 
       100.0 * shared_blks_hit / nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent
FROM pg_stat_statements 
ORDER BY total_time DESC 
LIMIT 5;

but I don't know how to interpret stddev_time (apparently this can show the queries that are causing problems)

And I don't understand how to interpret the following value:

100.0 * shared_blks_hit / nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent

Is it better when it's close to 0 or 100?

1

There are 1 best solutions below

0
On

stddev_time shows the standard deviation of the execution times for this statement. If this value is close to zero, the statement has about the same execution time whenever it is run.

Large stddev_time values mean that the statement has widely varying run times, either because the run time varies greatly depending on the constant values or because a lot of table or index blocks are touched, and the run time depends on whether they happen to be cached or not.

The hit_percent this query calculates shows what percentage of the blocks needed are found in the cache. 100 is the best value, showing that only cached blocks are needed.