PG-320: Removing the query state code from the view.

The query status monitoring code was used to track the current query state, for example,     
parsing, executing and finishing. After careful review, we have figured out that  
it does not make sense while a lot of time same query is running. Therefore it  
is also consuming resources. This commit will remove that feature. The upgrade
SQL from 1.0 - 2.0 is also updated.
This commit is contained in:
Ibrar Ahmed
2022-11-15 16:31:37 +00:00
parent fddc0967e3
commit db5a6aa30e
19 changed files with 536 additions and 200 deletions

View File

@@ -26,19 +26,6 @@ $$ LANGUAGE SQL;
-- Some generic utility function used internally.
CREATE FUNCTION get_state(state_code int8) RETURNS TEXT AS
$$
SELECT
CASE
WHEN state_code = 0 THEN 'PARSING'
WHEN state_code = 1 THEN 'PLANNING'
WHEN state_code = 2 THEN 'ACTIVE'
WHEN state_code = 3 THEN 'FINISHED'
WHEN state_code = 4 THEN 'FINISHED WITH ERROR'
END
$$
LANGUAGE SQL PARALLEL SAFE;
CREATE FUNCTION get_cmd_type (cmd_type INTEGER) RETURNS TEXT AS
$$
SELECT
@@ -129,7 +116,6 @@ CREATE FUNCTION pg_stat_monitor_internal(
OUT planid text,
OUT query text,
OUT query_plan text,
OUT state_code int8,
OUT top_queryid text,
OUT top_query text,
OUT application_name text,
@@ -233,9 +219,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
cpu_sys_time,
wal_records,
wal_fpi,
wal_bytes,
state_code,
get_state(state_code) as state
wal_bytes
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
ORDER BY bucket_start_time;
RETURN 0;
@@ -292,9 +276,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
wal_records,
wal_fpi,
wal_bytes,
state_code,
get_state(state_code) as state,
-- PostgreSQL-13 Specific Coulumns
plans_calls
FROM pg_stat_monitor_internal(TRUE) p, pg_database d WHERE dbid = oid
@@ -352,8 +333,6 @@ CREATE VIEW pg_stat_monitor AS SELECT
wal_records,
wal_fpi,
wal_bytes,
state_code,
get_state(state_code) as state,
-- PostgreSQL-14 Specific Columns
plans_calls,