postgresql monitoring setup commands

Reset all statistics

select * from pg_stat_reset();

select * from pg_stat_statements_reset();


Enable Stats by adding the parameter group file in AWS

Where you need to enable the monitoring and  

# add pg_stat_statements to your postgresql.conf and restart the server

shared_preload_libraries = 'pg_stat_statements'


From <https://github.com/cybertec-postgresql/pgwatch2> 



select dbid, queryid,  calls, ROUND(total_time)/1000 as TTL_in_s, round(min_time)/1000 as Min_in_S, round(max_time)/1000 as max_in_s,rows ,

rows/calls as AvgResultCnt,query from "pg_stat_statements"   order by 3 desc;


SELECT funcname, calls,CAST(total_time/1000 AS DOUBLE precision) as TotalTimei_in_s,CAST (total_time/1000/calls AS INTEGER ) as AvgExecution_Time_In_SecondsPerCall FROM pg_stat_user_functions;


Comments

Popular posts from this blog

Command Line tool for Android and iOS [ adb and cfgutil ]

Convert Chrome recording to Vugen Script

Jmeter-CheatSheet