Hologres provides slow query logs that, by default, capture DML statements that take longer than 100 ms to execute and all DDL statements. Hologres uses this log data to provide SQL diagnostics. You can analyze trends and details across various dimensions to understand instance usage and apply optimizations for improved performance. This topic describes how to use SQL diagnostics.
Features and recommendations
SQL diagnostics supports the following items:
|
Diagnostic item |
Description |
Total queries |
Total number of queries in the selected time range. |
Successful queries |
Total number of successful queries in the selected time range. |
Failed queries |
Total number of failed queries in the selected time range. |
Failed query details |
Shows error codes and corresponding failure counts to help troubleshoot problematic queries. Also displays representative queries and detailed error information. You can go to Query Insight for more details or refer to the Error code reference to identify specific causes and improve instance stability. |
Success and failure query trends |
Shows the ratio of successful to failed queries over the selected time range to help assess overall query performance. |
Query duration distribution trend |
Shows the trend of query duration distribution over the selected time range. By default, only |
DML trend |
Shows the execution trend of DML queries. By default, only |
DDL trend |
Shows the execution trend of DDL queries. Includes only the following DDL statements: |
Query source application distribution or trend |
Shows query distribution or trend by the Analyze applications contributing the most queries. Assign distinct |
User-based query distribution or trend |
Shows query distribution or trend by the Clearly analyze user query behavior. Use separate usernames for different tasks instead of sharing one account to simplify anomaly detection. |
Execution engine query trend |
Shows query execution trends by execution engine over the selected time range. Hologres uses different execution engines based on query characteristics, including HQE, PQE, SDK, or FixedQE. For details, see Service architecture. Avoid PQE queries when possible. Rewrite them as HQE queries for better performance. |
Notes
-
SQL diagnostics excludes system-related SQL statements using the following filter:
WHERE usename != 'system' AND client_addr != '127.0.0.1' AND (application_name IS NULL OR application_name NOT IN ('AutoPartition', 'holoweb_system', 'HgGenInQuery')) -
By default, the
hologres.hg_query_logtable captures only DML statements that take longer than 1 s to execute and all DDL statements. SQL diagnostics analyzes all DML and DDL statements that take longer than 100 ms to execute. If thehologres.hg_query_logtable shows fewer queries than SQL diagnostics, this is because the table includes only queries that exceed 1 s. You can adjust thelog_min_duration_statementparameter to capture queries that take longer than 100 ms to execute. For more information, see View and analyze slow query logs. -
Similar to slow query logs, SQL diagnostics retains data for only the past month.
-
Data is updated on a T+1 basis. You can query data from T-1 (the previous day) and earlier within the past month. By default, the data from the previous day is displayed. You can adjust the time range as needed.
-
SQL diagnostics uses the same permissions as slow query logs. For more information about how to grant permissions, see Grant viewing permissions.
Procedure
You can use HoloWeb to view SQL diagnostics.
-
Log on to the HoloWeb console. For more information, see Connect to HoloWeb and run a query.
-
In the top navigation bar, click Diagnostics and Optimization.
-
In the navigation pane on the left, choose Instance Diagnosis > SQL Diagnostics.
-
At the top of the SQL Diagnostics page, set the query conditions.
Query parameters:
Parameter
Required
Description
Instance name
Yes
Name of the instance to query for slow queries. Defaults to the currently logged-in instance.
Time range
Yes
Time range for slow queries. Defaults to Previous Day. Select up to one month of historical data.
-
Click Submit to view the results.
Intelligent SQL error diagnostics
If a query fails, the HoloWeb SQL Editor displays SQL diagnostics information. In addition, Query Insight provides intelligent diagnostics and automatically returns the cause of the failure and the solution to the SQL Editor. This feature helps you resolve failed queries more efficiently.
Error code reference
|
Error code |
Description |
Common full error messages |
Solution |
|
HG_ERRCODE_FDW_ERROR |
This error occurs when you import MaxCompute foreign table metadata into Hologres. It is typically caused by unsupported table types. |
|
For more information, see HG_ERRCODE_FDW_ERROR. |
|
ERRCODE_FDW_ERROR |
This error occurs during foreign table queries. |
|
Resolve the issue based on the specific error message. For more information, see ERRCODE_FDW_ERROR. |
|
This error indicates a violation of a unique constraint. It commonly occurs when you insert duplicate primary key values. |
|
|
|
This error indicates a violation of a CHECK constraint. It commonly occurs when you write data to a Hologres partitioned table and the partition values do not match the defined partitioning scheme. For example, you write data that is intended for partition |
|
Verify that the partition data matches the defined partition values and correct any mismatched data. |
|
This error indicates a violation of a NOT NULL constraint. It commonly occurs when you insert null values into a field that does not allow null values. |
|
Clean the dirty data. |
|
ERRCODE_UNDEFINED_TABLE |
The table does not exist. This error typically occurs if a table was recently created but its metadata has not been refreshed, or if a table is truncated or dropped during query execution. |
|
You can use Query Insight to check for concurrent TRUNCATE or DROP operations and then retry the task. For more information, see Query Insight. |
|
An unexpected internal error occurred. The instance may have experienced a breakdown or the query was unexpectedly interrupted. |
|
None available. |
|
The query was canceled. This error is typically caused by client-side timeout settings or by a TRUNCATE or DROP operation on the table. |
|
For more information about solutions, see Manage queries. |
|
The feature is not supported. |
|
For more information about solutions, see Common issues with Hologres SQL statements. |
|
ERRCODE_UNDEFINED_OBJECT |
An undefined object exists. This error is typically caused by a missing column or table group. |
|
|
|
The current account does not have the required permissions. You must grant the required permissions to the account. |
|
For more information about solutions, see Hologres permissions. |
|
The query failed due to an out-of-memory (OOM) error. |
|
For more information about solutions, see OOM troubleshooting guide. |
|
A data type mismatch occurred. This error typically occurs when the data type that is expected by an expression is different from the actual data type of a field. |
|
Verify that the columns in the SQL statement match. |
|
The SQL statement contains a division operation in which the divisor is |
|
You can clean the dirty data or configure a Grand Unified Configuration (GUC) parameter to suppress division-by-zero errors. For more information, see Function usage. |
|
ERRCODE_STRING_DATA_RIGHT_TRUNCATION |
A string right truncation error occurs when the value of a VARCHAR field exceeds the length that is specified when the table is created. |
|
Re-create the table and specify a greater length for the VARCHAR field, or change the data type of the field to TEXT. |
|
The query exceeds the limits that are imposed by Hologres. This error typically occurs when too many partitions, rows, or bytes are scanned from a foreign table. |
|
The limits for foreign table queries are exceeded. For more information about solutions, see MaxCompute integration: Common issues and diagnostics. |
|
ERRCODE_SYNTAX_ERROR |
The SQL statement has a syntax error. |
|
Check the syntax of your SQL statement. |
|
ERRCODE_UNDEFINED_FUNCTION |
This error typically indicates that an unsupported function is used. The error may be caused by incorrect function syntax, a missing extension, or a function that is not supported. |
|
Use the correct function syntax to avoid errors such as missing extensions. For more information, see Function reference. |
|
ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED |
You do not have the read permissions on the foreign table. |
|
For more information about solutions, see MaxCompute permissions. |
|
A duplicate object exists. This error typically occurs when you create a duplicate extension, publication, or role. |
|
If the object already exists, do not create it again. |
|
An invalid text representation is used. This error commonly occurs when you convert strings that contain invalid data to other data types, such as converting an empty string ("") to an INT. |
|
Clean the dirty data. |
|
ERRCODE_BAD_COPY_FILE_FORMAT |
The file or data format is incorrect during the execution of a COPY command. This error often occurs because the data contains the delimiter that is specified in the COPY command, such as a space. This causes a column count mismatch. |
|
Clean the dirty data. |
|
ERRCODE_UNDEFINED_COLUMN |
The query references a column that does not exist. |
|
Check the syntax of your SQL statement. |
|
ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE |
The numeric value is out of the valid range:
|
|
Check for dirty data or incorrect type definitions and adjust the column type. |
|
ERRCODE_DATETIME_FIELD_OVERFLOW |
A time-related field, such as timestamp, timestamptz, date, time, or timetz, contains an out-of-range value. For example, you write |
|
Clean the dirty data. |
|
ERRCODE_INVALID_PARAMETER_VALUE |
The parameter value is invalid. This error typically occurs when parameters do not meet the requirements. You can resolve the issue based on the specific error message. For example, the error message |
|
Check the syntax of your SQL statement. |
|
ERRCODE_INVALID_DATETIME_FORMAT |
The date format is invalid. The date data does not conform to the required format, such as in |
|
Clean the dirty data. |
|
ERRCODE_CHARACTER_NOT_IN_REPERTOIRE |
The character is outside the encoding range. This error commonly occurs when an invalid character is outside the UTF-8 encoding range. |
|
Clean the dirty data. |
|
ERRCODE_DUPLICATE_TABLE |
A duplicate table exists. This error commonly occurs when you try to create a table that already exists. |
|
If the table already exists, do not create it again. |
|
ERRCODE_UNTRANSLATABLE_CHARACTER |
The character cannot be converted to the target format. |
Note
This message indicates that a character that is encoded in UTF-8 has no equivalent in the target GBK encoding. |
Clean the dirty data. |
|
ERRCODE_GROUPING_ERROR |
A grouping error occurred. This error is related to GROUP BY clauses. |
|
Check the syntax of your SQL statement. Fields that are used in aggregate functions must be included in the GROUP BY clause. |
|
The transaction is in an invalid state. Transaction-related operations are not allowed. For example, you call SET_TABLE_PROPERTY to create a distribution key outside the transaction in which the CREATE TABLE statement is executed. |
|
The |
|
ERRCODE_AMBIGUOUS_COLUMN |
The column reference is ambiguous. This error occurs when a column name can refer to multiple columns. For example, in |
|
Check the syntax of your SQL statement. |
|
ERRCODE_DUPLICATE_COLUMN |
A duplicate column exists. This error commonly occurs when you declare the same field multiple times when you create a table. |
|
Check the syntax of your SQL statement. |
|
ERRCODE_AMBIGUOUS_FUNCTION |
The function reference is ambiguous. This error occurs when a function supports multiple input types but the data type of the passed argument is not explicitly specified. |
For example, the `to_char` function has the syntax The |
Check the syntax of your SQL statement. |
|
ERRCODE_INVALID_COLUMN_DEFINITION |
The column definition is invalid. In Hologres, this error commonly occurs when the precision for a Numeric or Decimal type is not specified. |
|
Clean the dirty data. |
|
ERRCODE_INVALID_CATALOG_NAME ERRCODE_UNDEFINED_DATABASE |
The specified database does not exist. |
None available |
Verify that the database exists. |
|
ERRCODE_CANNOT_COERCE |
This error occurs when data cannot be converted between two types. |
|
Check the syntax of your SQL statement. |
|
ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST |
Dependent objects still exist. This error commonly occurs when you delete an object on which other objects depend. For example, you try to delete a schema that contains tables. |
None available |
Resolve the dependencies first. For more information, see Delete accounts. |
|
ERRCODE_UNDEFINED_SCHEMA or ERRCODE_INVALID_SCHEMA_NAME |
The specified schema does not exist. |
|
Verify that the schema exists. If it does not exist, create it. |
|
ERRCODE_DUPLICATE_DATABASE |
A duplicate database exists. This error occurs when you try to create a database that already exists. |
None available |
If the database already exists, do not create it again. |
|
AutoAnalyze-Failed |
The Auto Analyze feature failed for specific reasons. |
|
Auto Analyze failures are typically related to the backend. You can submit a ticket for investigation. |
|
Import Foreign Table Not Found |
The foreign table is not found. |
|
Verify that the foreign table that you want to access exists. |
|
Cannot Acquire Lock In Time |
This error typically occurs when a lock fails to be acquired. High-concurrency queries and DROP operations on the same table can cause deadlocks on backend nodes. This blocks all operations on that table. |
|
For more information about solutions, see Locks and lock troubleshooting. |
|
An unexpected error occurred. |
|
This is an unexpected error. You can submit a ticket for investigation. |