Updated on 2025-05-29 GMT+08:00

GS_SQL_COUNT

GS_SQL_COUNT displays statistics about five types of running statements (SELECT, INSERT, UPDATE, DELETE, and MERGE INTO) on the current node of the database.

  • When a common user queries the GS_SQL_COUNT view, statistics about the current node of the user are displayed. When an administrator queries the GS_SQL_COUNT view, statistics about the current node of all users are displayed. In the multi-tenancy scenario, global information is returned if this view is accessed in a non-PDB, and information about a PDB is returned if this view is accessed in the PDB.
  • When the database or the node is restarted, the statistics are cleared and the counting restarts.
  • The system counts when a node receives a query, including a query inside the database.
Table 1 GS_SQL_COUNT columns

Name

Type

Description

node_name

name

Node name.

user_name

name

Username.

select_count

bigint

Statistical result of the SELECT statement.

update_count

bigint

Statistical result of the UPDATE statement.

insert_count

bigint

Statistical result of the INSERT statement.

delete_count

bigint

Statistical result of the DELETE statement.

mergeinto_count

bigint

Statistical result of the MERGE INTO statement.

ddl_count

bigint

Number of DDL statements. The statistics include the SQL statements executed by users and the SQL statements executed by database background threads, including TRUNCATE, VACUUM, ANALYZE, and CREATE (excluding CREATE ROLE and CREATE USER), DROP (excluding DROP ROLE and DROP USER), and ALTER (excluding ALTER ROLE, ALTER USER, and ALTER DEFAULT PRIVILEGES), REINDEX, and COMMENT statements.

dml_count

bigint

Number of DML statements. The statistics include the SQL statements executed by users and the SQL statements executed by database background threads, including UPDATE, INSERT, DELETE, MERGE, PREPARE, EXPLAIN, SHOW, LOCK, COPY, CLUSTER, ANONYMOUS, DELTA, EXECUTE, MOVE, FETCH, CLOSE, DEALLOCATE, DECLARE and LOAD statements.

dcl_count

bigint

Number of DCL statements. The statistics include the SQL statements executed by users and database background threads, including CREATE ROLE, CREATE USER, DROP ROLE, DROP USER, ALTER ROLE, ALTER USER, ALTER DEFAULT PRIVILEGES, GRANT, REVOKE, REASSIGN, and SET statements.

total_select_elapse

bigint

Total response time of SELECT statements (unit: μs).

avg_select_elapse

bigint

Average response time of SELECT statements (unit: μs).

max_select_elapse

bigint

Maximum response time of SELECT statements (unit: μs).

min_select_elapse

bigint

Minimum response time of SELECT statements (unit: μs).

total_update_elapse

bigint

Total response time of UPDATE statements (unit: μs).

avg_update_elapse

bigint

Average response time of UPDATE statements (unit: μs).

max_update_elapse

bigint

Maximum response time of UPDATE statements (unit: μs).

min_update_elapse

bigint

Minimum response time of UPDATE statements (unit: μs).

total_insert_elapse

bigint

Total response time of INSERT statements (unit: μs).

avg_insert_elapse

bigint

Average response time of INSERT statements (unit: μs).

max_insert_elapse

bigint

Maximum response time of INSERT statements (unit: μs).

min_insert_elapse

bigint

Minimum response time of INSERT statements (unit: μs).

total_delete_elapse

bigint

Total response time of DELETE statements (unit: μs).

avg_delete_elapse

bigint

Average response time of DELETE statements (unit: μs).

max_delete_elapse

bigint

Maximum response time of DELETE statements (unit: μs).

min_delete_elapse

bigint

Minimum response time of DELETE statements (unit: μs).

dbid

oid

ID of the database to which the five types of statements (SELECT, INSERT, UPDATE, DELETE, and MERGE INTO) belong.

user_dml_count

bigint

Number of DML statements executed by users.

bg_dml_count

bigint

Number of DML statements executed by the database backend thread.