All Products
Search
Document Center

PolarDB:Schema

Last Updated:Dec 22, 2022

This topic describes the table schemas and related fields of the mysql.sql_sharing and information_schema.sql_sharing tables used by the SQL Trace feature.

mysql.sql_sharing

The sql_sharing table is an InnoDB system table in a PolarDB for MySQL database. The table is used to store specified SQL statements that need to be tracked. The following example shows the schema of the sql_sharing table.

Note

The sql_sharing table is automatically created by the system upon startup.

CREATE TABLE `sql_sharing` (
  `Id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `Sql_id` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `Schema_name` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `Type` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `Digest_text` longtext COLLATE utf8_bin,
  `Plan_id` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `Plan` text COLLATE utf8_bin,
  `Version` int(11) unsigned DEFAULT NULL,
  `Create_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  `Update_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  `Extra_info` longtext COLLATE utf8_bin,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `sqlid_schema_type` (`Sql_id`,`Schema_name`,`Type`)
) /*!50100 TABLESPACE `mysql` */ ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

The following table describes the fields that are included in the table schema.

Field

Description

Id

The auto-increment ID of a data row in the mysql.sql_sharing table.

Sql_id

The ID of the templated SQL statement.

Schema_name

The name of the schema on which SQL statements are executed.

Type

The features that use the record.

Digest_text

The content of the templated SQL statement.

Plan_id

The ID of the execution plan.

Plan

The name of the execution plan.

Version

The version number of the record in the system.

Create_time

The time when the record is inserted.

Update_time

The time when the record is updated.

Extra_info

The additional information recorded by the system.

information_schema.sql_sharing

The sql_sharing memory table in the information_schema database is used to record the execution plan of SQL statements that are tracked by the SQL Trace feature and collect statistics on the execution of the SQL statements. The table has the following schema.

Note

The sql_sharing table is automatically created by the system upon startup.

CREATE TEMPORARY TABLE `SQL_SHARING` (
  `TYPE` varchar(16) DEFAULT NULL,
  `SQL_ID` varchar(64) DEFAULT NULL,
  `SCHEMA_NAME` varchar(64) DEFAULT NULL,
  `DIGEST_TEXT` varchar(2048) DEFAULT NULL,
  `PLAN_ID` varchar(64) DEFAULT NULL,
  `PLAN` varchar(1024) DEFAULT NULL,
  `PLAN_EXTRA` varchar(1024) DEFAULT NULL,
  `ERROR_CODE` bigint(21) DEFAULT NULL,
  `REF_BY` varchar(512) DEFAULT NULL,
  `FIRST_LOAD_TIME` datetime DEFAULT NULL,
  `LAST_HIT_TIME` datetime DEFAULT NULL,
  `EXECUTIONS` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_WAIT_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_WAIT_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_WAIT_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_EXEC_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_EXEC_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_EXEC_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_ROWS_SENT` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_ROWS_SENT` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_ROWS_SENT` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_ROWS_EXAMINED` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_ROWS_EXAMINED` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_ROWS_EXAMINED` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_ROWS_AFFECTED` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_ROWS_AFFECTED` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_ROWS_AFFECTED` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_LOGICAL_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_LOGICAL_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_LOGICAL_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_PHY_SYNC_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_PHY_SYNC_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_PHY_SYNC_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `SUM_PHY_ASYNC_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MIN_PHY_ASYNC_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `MAX_PHY_ASYNC_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
  `EXTRA` varchar(1024) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8;

The following table describes the fields that are included in the table schema.

Field

Description

TYPE

The type of the record. Valid values:

  • SQL: the templated SQL statement

  • PLAN: the execution plan generated when the templated SQL statement is being executed

SQL_ID

The ID of the templated SQL statement.

SCHEMA_NAME

The name of the schema on which SQL statements are executed.

DIGEST_TEXT

The content of the templated SQL statement.

PLAN_ID

The ID of the execution plan.

PLAN

The name of the execution plan.

PLAN_EXTRA

The additional information, such as which method is used to access the table and whether to use the prepared statement protocol to execute the templated SQL statement on the table. You can scan full table, select index range, and use the same index to access the table.

ERROR_CODE

The error code returned.

REF_BY

The feature that uses SQL statements or the execution plan. Valid values:

  • SQL_TRACE: All statements are tracked.

  • SQL_TRACE(DEMAND): Specified SQL statements are tracked.

FIRST_LOAD_TIME

The time when SQL statements and execution plan are first recorded in memory.

LAST_HIT_TIME

The time when SQL statements and execution plan were last executed.

EXECUTIONS

The total executions of the templated SQL statement.

SUM_WAIT_TIME

The wait time required to execute SQL statements. (Unit: microseconds)

MIN_WAIT_TIME

The minimum wait time. (Unit: microseconds)

MAX_WAIT_TIME

The maximum wait time. (Unit: microseconds)

SUM_EXEC_TIME

The total amount of time required to execute SQL statements. (Unit: microseconds)

MIN_EXEC_TIME

The minimum execution time. (Unit: microseconds)

MAX_EXEC_TIME

The maximum execution time. (Unit: microseconds)

SUM_ROWS_SENT

The total number of returned rows.

MIN_ROWS_SENT

The minimum number of returned rows.

MAX_ROWS_SENT

The maximum number of returned rows.

SUM_ROWS_EXAMINED

The total number of scanned rows.

MIN_ROWS_EXAMINED

The minimum number of scanned rows.

MAX_ROWS_EXAMINED

The maximum number of scanned rows.

SUM_ROWS_AFFECTED

The total number of affected rows.

MIN_ROWS_AFFECTED

The minimum number of affected rows.

MAX_ROWS_AFFECTED

The maximum number of affected rows.

SUM_LOGICAL_READ

The total number of logical reads.

MIN_LOGICAL_READ

The minimum number of logical reads.

MAX_LOGICAL_READ

The maximum number of logical reads.

SUM_PHY_SYNC_READ

The total number of physical synchronous reads.

MIN_PHY_SYNC_READ

The minimum number of physical synchronous reads.

MAX_PHY_SYNC_READ

The maximum number of physical synchronous reads.

SUM_PHY_ASYNC_READ

The total number of physical asynchronous reads.

MIN_PHY_ASYNC_READ

The minimum number of physical asynchronous reads.

MAX_PHY_ASYNC_READ

The maximum number of physical asynchronous reads.

EXTRA

The additional information.