mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Add views and functions to monitor hot standby query conflicts
Add the view pg_stat_database_conflicts and a column to pg_stat_database, and the underlying functions to provide the information.
This commit is contained in:
@ -71,6 +71,12 @@ extern Datum pg_stat_get_db_tuples_fetched(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_tuples_inserted(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_tuples_updated(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_tuples_deleted(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_tablespace(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_lock(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_snapshot(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_bufferpin(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_startup_deadlock(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS);
|
||||
|
||||
extern Datum pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS);
|
||||
@ -1129,6 +1135,101 @@ pg_stat_get_db_tuples_deleted(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_tablespace(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (dbentry->n_conflict_tablespace);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_lock(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (dbentry->n_conflict_lock);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_snapshot(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (dbentry->n_conflict_snapshot);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_bufferpin(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (dbentry->n_conflict_bufferpin);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_startup_deadlock(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (dbentry->n_conflict_startup_deadlock);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid dbid = PG_GETARG_OID(0);
|
||||
int64 result;
|
||||
PgStat_StatDBEntry *dbentry;
|
||||
|
||||
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
|
||||
result = 0;
|
||||
else
|
||||
result = (int64) (
|
||||
dbentry->n_conflict_tablespace +
|
||||
dbentry->n_conflict_lock +
|
||||
dbentry->n_conflict_snapshot +
|
||||
dbentry->n_conflict_bufferpin +
|
||||
dbentry->n_conflict_startup_deadlock);
|
||||
|
||||
PG_RETURN_INT64(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user