SQL Self-Diagnosis

Performance issues may occur when you run the INSERT/UPDATE/DELETE/SELECT/MERGE INTO or CREATE TABLE AS statement. The product supports automatic performance diagnosis and saves related diagnosis information to Real-time Top SQL. When enable_resource_track is set to on, the diagnosis information is dumped to Historical Top SQL. You can query the warning column in the GS_WLM_SESSION_STATISTICS, GS_WLM_SESSION_HISTORY, and GS_WLM_SESSION_INFO views to obtain reference information for performance tuning.

  • Alarms that can trigger SQL self-diagnosis depend on the settings of resource_track_level.

    When resource_track_level is set to query, you can diagnose alarms such as uncollected multi-column/single-column statistics, unpruned partitions, and failure of pushing down SQL statements. When resource_track_level is set to perf or operator, all alarms can be diagnosed.

  • Whether a SQL plan will be diagnosed depends on the settings of resource_track_cost.

    A SQL plan will be diagnosed only if its execution cost is greater than resource_track_cost. You can use the EXPLAIN keyword to check the plan execution cost.

  • When EXPLAIN PERFORMANCE or EXPLAIN VERBOSE is executed, SQL self-diagnosis information, except the ones without multi-column statistics, will be generated. For details, see SQL Execution Plan.

Constraints

  1. An alarm contains a maximum of 2048 characters. If the length of an alarm exceeds this value (for example, a large number of long table names and column names are displayed in the alarm when their statistics are not collected), a warning instead of an alarm will be reported.

    WARNING, "Planner issue report is truncated, the rest of planner issues will be skipped"
    
  2. If a query statement contains the Limit operator, alarms of operators lower than Limit will not be reported.

  3. For alarms about data skew and inaccurate estimation, only alarms on the lower-layer nodes in a plan tree will be reported. This is because the same alarms on the upper-level nodes may be triggered by problems on the lower-layer nodes. For example, if data skew occurs on the Scan node, data skew may also occur in operators (for example, Hashagg) at the upper layer.