All Products
Search
Document Center

Hologres:SQL diagnostics

Last Updated:Feb 04, 2026

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 SELECT, INSERT, UPDATE, and DELETE queries are analyzed.

DML trend

Shows the execution trend of DML queries.

By default, only SELECT, INSERT, UPDATE, and DELETE queries are analyzed.

DDL trend

Shows the execution trend of DDL queries.

Includes only the following DDL statements: CREATE TABLE, DROP TABLE, TRUNCATE TABLE, ALTER TABLE, CALL, CREATE EXTENSION, CREATE FOREIGN TABLE, ALTER FOREIGN TABLE, IMPORT FOREIGN SCHEMA, DROP FOREIGN TABLE, CREATE SCHEMA, CREATE VIEW, DROP VIEW, GRANT, CREATE ROLE, ALTER ROLE, and COMMENT.

Query source application distribution or trend

Shows query distribution or trend by the application_name dimension.

Analyze applications contributing the most queries. Assign distinct application_name values to different task types to improve visibility in source distribution charts and detect anomalies.

User-based query distribution or trend

Shows query distribution or trend by the usename dimension.

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_log table 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 the hologres.hg_query_log table shows fewer queries than SQL diagnostics, this is because the table includes only queries that exceed 1 s. You can adjust the log_min_duration_statement parameter 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.

  1. Log on to the HoloWeb console. For more information, see Connect to HoloWeb and run a query.

  2. In the top navigation bar, click Diagnostics and Optimization.

  3. In the navigation pane on the left, choose Instance Diagnosis > SQL Diagnostics.

  4. 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.

  5. 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.

failed to import foreign schema from odps: Can't find file system factory

For more information, see HG_ERRCODE_FDW_ERROR.

ERRCODE_FDW_ERROR

This error occurs during foreign table queries.

  • failed to import foreign schema from odps: Authorization Failed: xxx

  • failed to import foreign schema from odps:Table not found -xxx

Resolve the issue based on the specific error message. For more information, see ERRCODE_FDW_ERROR.

  • ERRCODE_UNIQUE_VIOLATION

  • pk violates

This error indicates a violation of a unique constraint. It commonly occurs when you insert duplicate primary key values.

duplicate key value violates unique constraint DETAIL: xxx already exists.

  • Handle the duplicate primary key data.

  • If the error occurs with an INSERT statement, you can rewrite it using the INSERT INTO xx ON CONFLICT syntax to deduplicate data by primary key. For more information, see INSERT ON CONFLICT (UPSERT).

  • If the error occurs when you use the INSERT INTO xx ON CONFLICT syntax, the source data is duplicated. For more information about solutions, see INSERT ON CONFLICT (UPSERT).

  • ERRCODE_CHECK_VIOLATION

  • partition constraint

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 20240301 into partition 0240229.

new row for relation xx violates partition constraint DETAIL: Failing row contains (column1)=(xxxx).

Verify that the partition data matches the defined partition values and correct any mismatched data.

  • ERRCODE_NOT_NULL_VIOLATION

  • not-null constraint

  • UsageProblem

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.

null value in column xxx violates not-null constraint DETAIL: Failing row contains (null).

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.

Dispatch query failed: Table not found

You can use Query Insight to check for concurrent TRUNCATE or DROP operations and then retry the task. For more information, see Query Insight.

  • ERRCODE_INTERNAL_ERROR

  • ERPC_ERROR_CONNECTION_CLOSED

An unexpected internal error occurred. The instance may have experienced a breakdown or the query was unexpectedly interrupted.

  • Transaction xx is not found or it was expired and cancelled.

  • Query is cancelled

  • ERPC_ERROR_CONNECTION_CLOSED

None available.

  • ERRCODE_QUERY_CANCELED

  • User canceled

  • CANCELLED

  • Query Is Cancelled

  • InternalQueryIsClosed

The query was canceled. This error is typically caused by client-side timeout settings or by a TRUNCATE or DROP operation on the table.

  • ERROR: canceling statement due to statement timeout

  • canceling statement due to user request

For more information about solutions, see Manage queries.

  • ERRCODE_FEATURE_NOT_SUPPORTED

  • Unsupported Feature

The feature is not supported.

  • Dynamic partition selector is not supported

  • ALTER TABLE CHANGE OWNER is not supported in SPM (Simple Permission Mode)

  • Feature not supported: insert into parent table

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.

  • column xxx does not exist

  • Table group xxx does not exist.

  • Create the missing object.

  • Verify that the object name that is referenced in the SQL statement is correct.

  • ERRCODE_INSUFFICIENT_PRIVILEGE

  • permission denied

The current account does not have the required permissions. You must grant the required permissions to the account.

  • ERROR: permission denied for schema xxx

  • ERROR: permission denied for foreign table table_info

For more information about solutions, see Hologres permissions.

  • ERRCODE_OUT_OF_MEMORY

  • OOM

The query failed due to an out-of-memory (OOM) error.

Total memory used by all existing queries exceeded memory limitation

For more information about solutions, see OOM troubleshooting guide.

  • ERRCODE_DATATYPE_MISMATCH

  • Unmatched Data Row Schema Number

  • Dataset Schema Not Match

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.

  • unmatched data row schema number

  • Datasets has different schema

Verify that the columns in the SQL statement match.

  • ERRCODE_DIVISION_BY_ZERO

  • division by zero

The SQL statement contains a division operation in which the divisor is 0.

division by zero

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.

value too long for type character varying(xx)

Re-create the table and specify a greater length for the VARCHAR field, or change the data type of the field to TEXT.

  • ERRCODE_PROGRAM_LIMIT_EXCEEDED

  • Exceed Odps Scan Limit

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.

  • number of read rows (xxxxx) exceeds limit (xxxxxxx)

  • number of partitions (xxx) scanned for "xxxx" exceeds the maximum allowed (xxx)

  • scan (xxx GB) for "xxxxx" exceeds the maximum allowed (xxx GB)

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.

syntax error at or near "xxxxx"

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.

  • function xxxxx does not exist

  • operator does not exist: xxxxxx

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.

check permission for foreign table scan failed: failed to check permission:MaxCompute error,Authorization Failed [4019], You have NO privilege 'odps:Select' on {xxxxxxxxxx}

For more information about solutions, see MaxCompute permissions.

  • ERRCODE_DUPLICATE_OBJECT

  • already exist

A duplicate object exists. This error typically occurs when you create a duplicate extension, publication, or role.

  • publication "xxxxx" already exists

  • extension "xxxxx" already exists

  • role "xxxxxxxx" already exists

If the object already exists, do not create it again.

  • ERRCODE_INVALID_TEXT_REPRESENTATION

  • invalid input

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.

invalid input syntax for integer: xxx

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.

  • extra data after last expected column. failed to query next

  • missing data for column "xxx". failed to query next

Clean the dirty data.

ERRCODE_UNDEFINED_COLUMN

The query references a column that does not exist.

column xxxxx 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:

  • The numeric data exceeds the defined range for the numeric type. For example, for the decimal(4,2) or numeric(4,2) type, the integer part can have a maximum of two digits, but the actual data is 100.

  • The INT or BIGINT value exceeds the valid range.

  • value "xxxxx" is out of range for type bigint

  • numeric field overflow

  • bigint out of range

  • integer out of 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 "877411-01-01 00:00:00+08" to a timestamptz column.

  • date/time field value out of range: "xxxxxx"

  • date out of range: "xxxxxx"

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 column "col" with type "float4" cannot be set as "bitmap_columns" indicates that the float4 type cannot be used for bitmap columns.

  • mismatched properties: table orientation is "column" but storage format is "sst"

  • resharding insert select table data failed : Dispatch query failed: internal error: Failed to get available shards for query

  • InsertOverwrite insert select table data failed : column a.unsign_type does not exist

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 SELECT TO_DATE('aa', 'YYYY-MM-DD');. Check your data.

  • invalid input syntax for type timestamp: ""

  • invalid input syntax for type date: ""

  • invalid value "" for "yyyy",Value must be an integer.

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.

invalid byte sequence for encoding "UTF8": 0xe9 0x80

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.

relation "xxxx" already exists

If the table already exists, do not create it again.

ERRCODE_UNTRANSLATABLE_CHARACTER

The character cannot be converted to the target format.

character with byte sequence 0xe4 0x9e 0xab in encoding "UTF8" has no equivalent in encoding "GBK"

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.

column "xxx" must appear in the GROUP BY clause or be used in an aggregate function

Check the syntax of your SQL statement. Fields that are used in aggregate functions must be included in the GROUP BY clause.

  • ERRCODE_INVALID_TRANSACTION_STATE

  • Usage Problem

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.

SET_TABLE_PROPERTY and CREATE TABLE statement are not in the same transaction

The CREATE TABLE statement and the CALL SET_TABLE_PROPERTY statement must be in the same transaction. You can use BEGIN; and COMMIT; to define a transaction.

ERRCODE_AMBIGUOUS_COLUMN

The column reference is ambiguous. This error occurs when a column name can refer to multiple columns. For example, in SELECT id FROM t1 INNER JOIN t2 ON t1.id = t2.id, the id field is not qualified with its table alias.

column reference "xxx" is ambiguous

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.

column "xxx" specified more than once

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 to_char(timestamp/timestamptz, text),

The to_char function has several signatures for numeric types, such as to_char(double precision, text) and to_char(int, text). Therefore, an expression such as to_char('2024-02-22', 'YYYY-MM-DD') causes an error because the first argument, '2024-02-22', is a string. To resolve this error, you must explicitly cast the string to a timestamp type. For example: to_char('2024-02-22'::timestamptz, 'YYYY-MM-DD').

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.

invalid definition of a numeric type

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.

cannot cast type date to integer

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.

schema "xxxx" 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.

  • query row count from analyze table

  • query from analyze table

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.

  • failed to get foregin table split:Table not found

  • Failed to get odps table:Not enable acid table

  • failed to get foregin table split:% 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.

internal error: Cannot acquire lock in time, current owners

For more information about solutions, see Locks and lock troubleshooting.

  • OTHER

  • QueryNextFTEFailed

  • QueryNextPQEFailed

  • ForeignSplitOrSchemaConnectionClosed

  • ConnectionRefused

  • ERPC_ERROR_TIMEOUT

  • ERPC_ERROR_CONNECTION_CLOSED

An unexpected error occurred.

  • kConnectError: channel is empty

  • ERPC_ERROR_CONNECTION_CLOSED

  • internal error: Connect timeout, err: std_exception: Connection refused

This is an unexpected error. You can submit a ticket for investigation.