Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Case: Adjusting the GUC Parameter best_agg_plan

Updated on 2022-06-11 GMT+08:00

Symptom

The t1 table is defined as follows:

1
create table t1(a int, b int, c int) distribute by hash(a);

Assume that the distribution column of the result set provided by the agg lower-layer operator is setA, and the group by column of the agg operation is setB, the agg operations can be performed in two scenarios in the stream framework.

  1. setA is a subset of setB.

    In this scenario, the aggregation result of the lower-layer result set is the correct result, which can be directly used by the upper-layer operator. For details, see the following figure:

    1
    2
    3
    4
    5
    6
    7
    explain select a, count(1) from t1 group by a;
     id |          operation           | E-rows | E-width | E-costs  
    ----+------------------------------+--------+---------+---------
      1 | ->  Streaming (type: GATHER) |     30 |       4 | 15.56   
      2 |    ->  HashAggregate         |     30 |       4 | 14.31   
      3 |       ->  Seq Scan on t1     |     30 |       4 | 14.14   
    (3 rows)
    
  2. setA is not a subset of setB.

    In this scenario, the Stream execution framework is classified into the following three plans:

    hashagg+gather(redistribute)+hashagg

    redistribute+hashagg(+gather)

    hashagg+redistribute+hashagg(+gather)

    GaussDB(DWS) provides the guc parameter best_agg_plan to intervene the execution plan, and forces the plan to generate the corresponding execution plan. This parameter can be set to 0, 1, 2, and 3.

    • When the value is set to 1, the first plan is forcibly generated.
    • When the value is set to 2 and if the group by column can be redistributed, the second plan is forcibly generated. Otherwise, the first plan is generated.
    • When the value is set to 3 and if the group by column can be redistributed, the third plan is generated. Otherwise, the first plan is generated.
    • When the value is set to 0, the query optimizer chooses the most optimal plan by the three preceding plans' evaluation cost.

    For details, see the following figure.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    set best_agg_plan to 1;
    SET
    explain select b,count(1) from t1 group by b;
     id |            operation            | E-rows | E-width | E-costs 
    ----+---------------------------------+--------+---------+---------
      1 | ->  HashAggregate               |      8 |       4 | 15.83   
      2 |    ->  Streaming (type: GATHER) |     25 |       4 | 15.83   
      3 |       ->  HashAggregate         |     25 |       4 | 14.33   
      4 |          ->  Seq Scan on t1     |     30 |       4 | 14.14   
    (4 rows)
    set best_agg_plan to 2;
    SET
    explain select b,count(1) from t1 group by b;
     id |                operation                | E-rows | E-width | E-costs 
    ----+-----------------------------------------+--------+---------+---------
      1 | ->  Streaming (type: GATHER)            |     30 |       4 | 15.85   
      2 |    ->  HashAggregate                    |     30 |       4 | 14.60   
      3 |       ->  Streaming(type: REDISTRIBUTE) |     30 |       4 | 14.45   
      4 |          ->  Seq Scan on t1             |     30 |       4 | 14.14   
    (4 rows)
    set best_agg_plan to 3;
    SET
    explain select b,count(1) from t1 group by b;
     id |                operation                | E-rows | E-width | E-costs 
    ----+-----------------------------------------+--------+---------+---------
      1 | ->  Streaming (type: GATHER)            |     30 |       4 | 15.84   
      2 |    ->  HashAggregate                    |     30 |       4 | 14.59   
      3 |       ->  Streaming(type: REDISTRIBUTE) |     25 |       4 | 14.59   
      4 |          ->  HashAggregate              |     25 |       4 | 14.33   
      5 |             ->  Seq Scan on t1          |     30 |       4 | 14.14   
    (5 rows)
    

Optimization

Generally, the optimizer chooses an optimal execution plan, but the cost estimation, especially that of the intermediate result set, has large deviations, which may result in large deviations in agg calculation. In this case, you need to use best_agg_plan to adjust the agg calculation model.

When the aggregation convergence ratio is very small, that is, the number of result sets does not become small obviously after the agg operation (5 times is a critical point), you can select the redistribute+hashagg or hashagg+redistribute+hashagg execution mode.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback