Locks held and statistics


Job details

Name: Locks held and statistics
Platform: Postgres
Category: Performance
Description: Shows locks held statistics.
Long description: Task shows locks held statistics.
Version: 1.6
Default schedule: 2,17,32,47 * * *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘postgres’]/.[hasengine=‘YES’ & pg_stat_activity_type3 = ‘1′]

Parameters

Name Default value Description
keep data for 7 The number of days to keep the data for.
ignore user Users that we do not want to see locks for.

Job Summary

SELECT * FROM dbw_locks_held_num_histr;
SELECT * FROM dbw_locks_held_histr;
SELECT * FROM dbw_users_online_histr;

Job Description and Functionality

The monitoring job titled “Locks held and statistics” focuses on capturing and analyzing lock information within a PostgreSQL database environment. Its capabilities include:

Job Configuration Details

Tables and functions created and used by this job include:

Key operations within these functions include aggregating lock data, filtering based on user, and maintaining a rolling window of historical data based on the “keep data for” parameter.

Dependencies and Cleanup

Dependencies include several self-referencing data tables and functions to ensure that all necessary components are available for the job’s execution. Cleanup on failure is enabled, ensuring that any partially completed operations do not leave the system in an inconsistent state.

Implementation

The implementation involves both DDL for creating necessary tables and procedural code for the PL/pgSQL functions handling the logic of data gathering, history management, and cleanup operations. These components are vital for the dynamic and automated handling of lock statistics within the database.

Reporting and Output

The job provides a detailed report that includes:

Tables and charts are dynamically generated based on current and historical data, offering a clear visual and tabular representation of lock statistics to database administrators.