هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

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
On this page

Show all

Dynamic Parameterized Path Pruning

Updated on 2024-05-20 GMT+08:00
Dynamic parameterized path pruning is supported in the following scenarios:
  1. Supported partitioning types: range partitioning, hash partitioning, and list partitioning.
  2. Supported operator types: index scan, index-only scan, and bitmap scan.
  3. Supported expression types: comparison expression (<, <=, =, >=, >) and logical expression.
CAUTION:

Dynamic parameterized path pruning does not support subquery expressions, STABLE and VOLATILE functions, cross-QueryBlock parameterized paths, BitmapOr operator, or BitmapAnd operator.

  • Typical scenarios where dynamic parameterized path pruning is supported are as follows:
    1. Comparison expressions
      -- Create partitioned tables and indexes.
      gaussdb=# CREATE TABLE t1 (c1 INT, c2 INT)
      PARTITION BY RANGE (c1)
      (
          PARTITION p1 VALUES LESS THAN(10),
          PARTITION p2 VALUES LESS THAN(20),
          PARTITION p3 VALUES LESS THAN(MAXVALUE)
      );
      gaussdb=# CREATE TABLE t2 (c1 INT, c2 INT)
      PARTITION BY RANGE (c1)
      (
          PARTITION p1 VALUES LESS THAN(10),
          PARTITION p2 VALUES LESS THAN(20),
          PARTITION p3 VALUES LESS THAN(MAXVALUE)
      );
      gaussdb=# CREATE INDEX t1_c1 ON t1(c1) LOCAL;
      gaussdb=# CREATE INDEX t2_c1 ON t2(c1) LOCAL;
      gaussdb=# CREATE INDEX t1_c2 ON t1(c2) LOCAL;
      gaussdb=# CREATE INDEX t2_c2 ON t2(c2) LOCAL;
      
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT /*+ nestloop(t1 t2) indexscan(t1) indexscan(t2) */ * FROM t2 JOIN t1 ON t1.c1 = t2.c1;
                                                                          QUERY PLAN                                                                     
      ---------------------------------------------------------------------------------------------------------------------------------------------------
       Data Node Scan
         Output: t2.c1, t2.c2, t1.c1, t1.c2
         Node/s: All datanodes
         Remote query: SELECT/*+ NestLoop(t1 t2) IndexScan(t1) IndexScan(t2)*/ t2.c1, t2.c2, t1.c1, t1.c2 FROM public.t2 JOIN public.t1 ON t1.c1 = t2.c1
      
       Remote SQL: SELECT/*+ NestLoop(t1 t2) IndexScan(t1) IndexScan(t2)*/ t2.c1, t2.c2, t1.c1, t1.c2 FROM public.t2 JOIN public.t1 ON t1.c1 = t2.c1
       Datanode Name: datanode1
         Nested Loop
           Output: t2.c1, t2.c2, t1.c1, t1.c2
           ->  Partition Iterator
                 Output: t2.c1, t2.c2
                 Iterations: 3
                 ->  Partitioned Index Scan using t2_c1 on public.t2
                       Output: t2.c1, t2.c2
                       Selected Partitions:  1..3
           ->  Partition Iterator
                 Output: t1.c1, t1.c2
                 Iterations: PART
                 ->  Partitioned Index Scan using t1_c1 on public.t1
                       Output: t1.c1, t1.c2
                       Index Cond: (t1.c1 = t2.c1)
                       Selected Partitions:  1 (ppi-pruning)
      
      (23 rows)
      
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT /*+ nestloop(t1 t2) indexscan(t1) indexscan(t2) */ * FROM t2 JOIN t1 ON t1.c1 < t2.c1;
                                  QUERY PLAN                             
      -------------------------------------------------------------------
       Streaming (type: GATHER)
         Output: t2.c1, t2.c2, t1.c1, t1.c2
         Node/s: All datanodes
         ->  Nested Loop
               Output: t2.c1, t2.c2, t1.c1, t1.c2
               ->  Streaming(type: BROADCAST)
                     Output: t2.c1, t2.c2
                     Spawn on: All datanodes
                     Consumer Nodes: All datanodes
                     ->  Partition Iterator
                           Output: t2.c1, t2.c2
                           Iterations: 3
                           ->  Partitioned Seq Scan on public.t2
                                 Output: t2.c1, t2.c2
                                 Distribute Key: t2.c1
                                 Selected Partitions:  1..3
               ->  Partition Iterator
                     Output: t1.c1, t1.c2
                     Iterations: PART
                     ->  Partitioned Index Scan using t1_c1 on public.t1
                           Output: t1.c1, t1.c2
                           Distribute Key: t1.c1
                           Index Cond: (t1.c1 < t2.c1)
                           Selected Partitions:  1 (ppi-pruning)
      (24 rows)
      
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT /*+ nestloop(t1 t2) indexscan(t1) indexscan(t2) */ * FROM t2 JOIN t1 ON t1.c1 < t2.c1;
                                  QUERY PLAN                             
      -------------------------------------------------------------------
       Streaming (type: GATHER)
         Output: t2.c1, t2.c2, t1.c1, t1.c2
         Node/s: All datanodes
         ->  Nested Loop
               Output: t2.c1, t2.c2, t1.c1, t1.c2
               ->  Streaming(type: BROADCAST)
                     Output: t2.c1, t2.c2
                     Spawn on: All datanodes
                     Consumer Nodes: All datanodes
                     ->  Partition Iterator
                           Output: t2.c1, t2.c2
                           Iterations: 3
                           ->  Partitioned Seq Scan on public.t2
                                 Output: t2.c1, t2.c2
                                 Distribute Key: t2.c1
                                 Selected Partitions:  1..3
               ->  Partition Iterator
                     Output: t1.c1, t1.c2
                     Iterations: PART
                     ->  Partitioned Index Scan using t1_c1 on public.t1
                           Output: t1.c1, t1.c2
                           Distribute Key: t1.c1
                           Index Cond: (t1.c1 > t2.c1)
                           Selected Partitions:  1..3 (ppi-pruning)
      (24 rows)
    2. Logical expressions
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT /*+ nestloop(t1 t2) indexscan(t1) indexscan(t2) */ * FROM t2 JOIN t1 ON t1.c1 = t2.c1 AND t1.c2 = 2;
                                                                                 QUERY PLAN                                                                            
      -----------------------------------------------------------------------------------------------------------------------------------------------------------------
       Data Node Scan
         Output: t2.c1, t2.c2, t1.c1, t1.c2
         Node/s: All datanodes
         Remote query: SELECT/*+ NestLoop(t1 t2) IndexScan(t1) IndexScan(t2)*/ t2.c1, t2.c2, t1.c1, t1.c2 FROM public.t2 JOIN public.t1 ON t1.c1 = t2.c1 AND t1.c2 = 2
      
       Remote SQL: SELECT/*+ NestLoop(t1 t2) IndexScan(t1) IndexScan(t2)*/ t2.c1, t2.c2, t1.c1, t1.c2 FROM public.t2 JOIN public.t1 ON t1.c1 = t2.c1 AND t1.c2 = 2
       Datanode Name: datanode1
         Nested Loop
           Output: t2.c1, t2.c2, t1.c1, t1.c2
           ->  Partition Iterator
                 Output: t1.c1, t1.c2
                 Iterations: 3
                 ->  Partitioned Index Scan using t1_c2 on public.t1
                       Output: t1.c1, t1.c2
                       Index Cond: (t1.c2 = 2)
                       Selected Partitions:  1..3
           ->  Partition Iterator
                 Output: t2.c1, t2.c2
                 Iterations: PART
                 ->  Partitioned Index Scan using t2_c1 on public.t2
                       Output: t2.c1, t2.c2
                       Index Cond: (t2.c1 = t1.c1)
                       Selected Partitions:  1..3 (ppi-pruning)
      
      (24 rows)
  • Typical scenarios where dynamic parameterized path pruning is not supported are as follows:
    1. BitmapOr and BitmapAnd operators
      gaussdb=# set enable_seqscan=off;
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT /*+ nestloop(t1 t2) */ * FROM t2 JOIN t1 ON t1.c1 = t2.c1 OR t1.c2 = 2;
      WARNING:  Statistics in some tables or columns(public.t2.c1, public.t1.c1, public.t1.c2) are not collected.
      HINT:  Do analyze for them in order to generate optimized plan.
                                    QUERY PLAN
      ----------------------------------------------------------------------
       Streaming (type: GATHER)
         Output: t2.c1, t2.c2, t1.c1, t1.c2
         Node/s: All datanodes
         ->  Nested Loop
               Output: t2.c1, t2.c2, t1.c1, t1.c2
               ->  Streaming(type: BROADCAST)
                     Output: t2.c1, t2.c2
                     Spawn on: All datanodes
                     Consumer Nodes: All datanodes
                     ->  Partition Iterator
                           Output: t2.c1, t2.c2
                           Iterations: 3
                           ->  Partitioned Seq Scan on public.t2
                                 Output: t2.c1, t2.c2
                                 Distribute Key: t2.c1
                                 Selected Partitions:  1..3
               ->  Partition Iterator
                     Output: t1.c1, t1.c2
                     Iterations: 3
                     ->  Partitioned Bitmap Heap Scan on public.t1
                           Output: t1.c1, t1.c2
                           Distribute Key: t1.c1
                           Recheck Cond: ((t1.c1 = t2.c1) OR (t1.c2 = 2))
                           Selected Partitions:  1..3
                           ->  BitmapOr
                                 ->  Partitioned Bitmap Index Scan on t1_c1
                                       Index Cond: (t1.c1 = t2.c1)
                                 ->  Partitioned Bitmap Index Scan on t1_c2
                                       Index Cond: (t1.c2 = 2)
      (29 rows)
    2. Implicit conversion
      gaussdb=# CREATE TABLE t3(c1 TEXT, c2 INT);
      CREATE TABLE
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT * FROM t1 JOIN t3 ON t1.c1 = t3.c1;
      WARNING:  Statistics in some tables or columns(public.t1.c1, public.t3.c1) are not collected.
      HINT:  Do analyze for them in order to generate optimized plan.
                                  QUERY PLAN
      -------------------------------------------------------------------
       Streaming (type: GATHER)
         Output: t1.c1, t1.c2, t3.c1, t3.c2
         Node/s: All datanodes
         ->  Nested Loop
               Output: t1.c1, t1.c2, t3.c1, t3.c2
               Join Filter: (t1.c1 = ((t3.c1)::bigint))
               ->  Partition Iterator
                     Output: t1.c1, t1.c2
                     Iterations: 3
                     ->  Partitioned Index Scan using t1_c1 on public.t1
                           Output: t1.c1, t1.c2
                           Distribute Key: t1.c1
                           Selected Partitions:  1..3
               ->  Materialize
                     Output: t3.c1, t3.c2, ((t3.c1)::bigint)
                     ->  Streaming(type: REDISTRIBUTE)
                           Output: t3.c1, t3.c2, ((t3.c1)::bigint)
                           Distribute Key: ((t3.c1)::bigint)
                           Spawn on: All datanodes
                           Consumer Nodes: All datanodes
                           ->  Seq Scan on public.t3
                                 Output: t3.c1, t3.c2, t3.c1
                                 Distribute Key: t3.c1
      (23 rows)
    3. Functions
      gaussdb=# EXPLAIN (VERBOSE ON, COSTS OFF) SELECT * FROM t1 JOIN t3 ON t1.c1 = LENGTHB(t3.c1);
                               QUERY PLAN                          
      -------------------------------------------------------------
       Nested Loop
         Output: t1.c1, t1.c2, t3.c1, t3.c2
         ->  Seq Scan on public.t3
               Output: t3.c1, t3.c2
         ->  Partition Iterator
               Output: t1.c1, t1.c2
               Iterations: 3
               ->  Partitioned Index Scan using t1_c1 on public.t1
                     Output: t1.c1, t1.c2
                     Index Cond: (t1.c1 = lengthb(t3.c1))
                     Selected Partitions:  1..3
      (11 rows)
      
      -- Clean up the environment.
      gaussdb=# DROP TABLE t1;
      gaussdb=# DROP TABLE t2;
      gaussdb=# DROP TABLE t3;

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback