El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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

Enabling Parallel Query

Updated on 2024-12-23 GMT+08:00

System Parameters and Status Variables

  • Table 1 lists the supported system parameters.
    Table 1 System parameters

    Parameter

    Level

    Description

    force_parallel_execute

    Global, Session

    Enables or disables parallel query. If this parameter is set to ON, parallel query is enabled.

    • Value range: ON and OFF
    • Default value: OFF

    parallel_max_threads

    Global

    Maximum number of active threads allowed for parallel execution. If the number of active threads in the current system exceeds the value of this parameter, parallel execution cannot be enabled for new queries.

    • Value range: 0 to 4294967295
    • Default value: 64

    parallel_default_dop

    Global, Session

    Default parallelism degree for parallel execution. If the parallelism degree is not specified in query statements, this parameter value is used.

    • Value range: 0 to 1024
    • Default value: 4

    parallel_cost_threshold

    Global, Session

    Cost threshold for enabling parallel execution. If the parallel execution cost of query statements exceeds the value of this parameter, parallel execution is enabled.

    • Value range: 0 to 4294967295
    • Default value: 1000

    parallel_queue_timeout

    Global, Session

    Waiting time of the parallel execution. If the waiting time exceeds the value of this parameter, new queries will be executed in single-thread mode.

    • Value range: 0 to 4294967295
    • Default value: 0

    parallel_memory_limit

    Global

    Maximum available memory for parallel execution. If the amount of memory used for parallel execution exceeds the value of this parameter, new queries will not be executed in parallel mode.

    • Value range: 0 to 4294967295
    • Default value: 104857600
  • Table 2 lists the supported status variables.
    Table 2 Status variables

    Variable

    Level

    Description

    PQ_threads_running

    Global

    Total number of concurrent threads that are running.

    PQ_memory_used

    Global

    Total memory used for parallel execution.

    PQ_threads_refused

    Global

    Total number of queries that fail to be executed in parallel due to the limit on the total number of threads.

    PQ_memory_refused

    Global

    Total number of queries that fail to be executed in parallel due to the limit on the total memory.

Enabling Parallel Query

You can enable or disable parallel query by configuring system parameters in the console or using hints in SQL statements.

  • Method 1: Configuring system parameters in the console

    Log in to the console and go to the Parameters page to configure the following system parameters:

    force_parallel_execute: determines whether to forcibly enable parallel execution.

    parallel_default_dop: indicates the parallelism degree for parallel execution. It controls the number of concurrent threads.

    parallel_cost_threshold: indicates the cost threshold for enabling parallel execution.

    Theses parameters can be modified at any time. The modifications will take effect immediately and you do not need to reboot the instance.

    For example, if you want to forcibly enable parallel execution, set the parallelism degree to 4, and set the minimum execution cost to 0, configure the parameters as follows:

    SET force_parallel_execute=ON
    SET parallel_default_dop=4
    SET parallel_cost_threshold=0
  • Method 2: Using hints in SQL statements

    Hints can be used to control whether a single statement is executed in parallel. If parallel execution is disabled by default, uses hints to enable parallel execution for specific SQL statements. You can also use hints to disable parallel execution for specified SQL statements.

    Enabling parallel execution:

    Enabling parallel execution: SELECT /*+ PQ() */... FROM...

    Enabling parallel execution and setting the parallelism degree to 8: SELECT /*+ PQ(8) */... FROM...

    Enabling parallel execution and set the parallel-executed table to t1: SELECT /*+ PQ(t1) */... FROM...

    Enabling parallel execution, set the parallel-executed table to t1, and set the parallelism degree to 8: SELECT /*+ PQ(t1 8) */... FROM...

    NOTE:

    SELECT is followed by PQ (Hints). Otherwise, the hints do not take effect. dop indicates the parallelism degree of a parallel query and its value ranges from 1 to min(parallel_max_threads, 1024).

    When the dop value exceeds the normal range, parallel query does not take effect.

    Disabling parallel execution: When parallel query is enabled, use the NO_PQ to disable parallel execution of a single SQL statement.

    SELECT /*+ NO_PQ */ … FROM …

    NOTE:

    NO_PQ (Hints) takes precedence over PQ (Hints). If an SQL statement contains NO_PQ (Hints), the SQL statement will not be executed concurrently even if PQ (Hints) is configured.

Checking the Statuses of Query Statements Executed in Parallel

Run the following SQL statement to display the statuses of query statements executed in parallel, as shown in Figure 1.

show status like "%PQ%"

Figure 1 Status

Use EXPLAIN to display the parallel execution plans of the query statements, as shown in Figure 2.

Figure 2 Parallel execution plan
NOTE:

Compared with a traditional execution plan, a parallel execution plan has one more row of records. In the first row of the query result, the parallel-executed tables and parallelism degree are displayed.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback