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
Help Center/ GaussDB/ Developer Guide(Distributed_3.x)/ SQL Optimization/ Hint-based Tuning/ Hint of Parameterized Paths at the Same Level

Hint of Parameterized Paths at the Same Level

Updated on 2024-05-07 GMT+08:00

Function

The predpush_same_level and nestloop_index hints are used to specify the generation of parameterized paths between tables or materialized views at the same level.

For details about cross-layer parameterized path hints, see Parameterized Path Hint.

Syntax

1
2
3
4
predpush_same_level([@queryblock] src, dest)
predpush_same_level([@queryblock] src1 src2 ..., dest)
[no] nestloop_index([@queryblock] dest[, index_list]) -- With indexes
[no] nestloop_index([@queryblock] dest[,(src1 src2 ...)]) -- With tables
NOTE:

The predpush_same_level parameter takes effect only when the predpushforce option in rewrite_rule is enabled.

nestloop_index has no requirement on rewrite_rule.

Parameter Description

  • no indicates that the parameterized path of hints is not used.
  • For details about @queryblock, see Hint Specifying the Query Block Where the Hint Is Located. @queryblock can be omitted, indicating that the hint takes effect in the current query block.
  • dest is the target table of the parameterized path, that is, the table where the indexes are located.
  • src is the parameter table of the parameterized path.
  • index_list is the index sequence used by the parameterized path, which consists of character strings separated by spaces.

Examples

To view the following plan example, you need to set the following parameters:

set enable_fast_query_shipping = off;
set enable_stream_operator = on;

1. Examples of nestloop_index:

  • Transfer t2.c1 and t3.c2 of t2 and t3 to the t1 table for index scanning (parameterized path).
    gaussdb=# explain (costs off) select /*+nestloop_index(t1,(t2 t3)) */* from t1,t2,t3 where t1.c1 = t2.c1 and t1.c2 = t3.c2;
                               QUERY PLAN                            
    -----------------------------------------------------------------
     Streaming (type: GATHER)
       Node/s: All datanodes
       ->  Nested Loop
             ->  Streaming(type: BROADCAST)
                   Spawn on: All datanodes
                   ->  Seq Scan on t3
             ->  Nested Loop
                   ->  Seq Scan on t2
                   ->  Index Scan using it1 on t1
                         Index Cond: ((c1 = t2.c1) AND (c2 = t3.c2))
    (10 rows)
  • Perform an index scan on it1 of the t1 table (parameterized path).
    gaussdb=# explain (costs off) select /*+NestLoop_Index(t1,it1) */* from t1,t2 where t1.c1 = t2.c1;
                   QUERY PLAN               
    ----------------------------------------
     Streaming (type: GATHER)
       Node/s: All datanodes
       ->  Nested Loop
             ->  Seq Scan on t2
             ->  Index Scan using it1 on t1
                   Index Cond: (c1 = t2.c1)
    (6 rows)

2. Example of predpush_same_level:

  • Prepare parameters.
    1
    2
    3
    4
    gaussdb=# set rewrite_rule = 'predpushforce';
    SET
    gaussdb=# set enable_fast_query_shipping=off;
    SET
    
  • Run the following statement to view the plan:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    gaussdb=# explain select * from t1, t2 where t1.c1 = t2.c1;
                                  QUERY PLAN
    -----------------------------------------------------------------------
     
     Streaming (type: GATHER)  (cost=16.98..34.22 rows=40 width=24)
       Node/s: All datanodes
       ->  Hash Join  (cost=16.36..32.66 rows=40 width=24)
             Hash Cond: (t1.c1 = t2.c1)
             ->  Seq Scan on t1  (cost=0.00..16.16 rows=40 width=12)
             ->  Hash  (cost=16.16..16.16 rows=40 width=12)
                   ->  Seq Scan on t2  (cost=0.00..16.16 rows=40 width=12)
    
    (7 rows)
    
  • The filter condition t1.c1 = t2.c2 is displayed on Join. In this case, predpush_same_level(t1, t2) can be used to push the condition down to the scan operator of t2.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    gaussdb=# explain select /*+predpush_same_level(t1, t2)*/ * from t1, t2 where t1.c1 = t2.c1;
                                    QUERY PLAN
    ---------------------------------------------------------------------------
     
     Streaming (type: GATHER)  (cost=0.62..70.20 rows=40 width=24)
       Node/s: All datanodes
       ->  Nested Loop  (cost=0.00..68.64 rows=40 width=24)
             ->  Seq Scan on t1  (cost=0.00..16.16 rows=40 width=12)
             ->  Index Scan using it2 on t2  (cost=0.00..3.27 rows=1 width=12)
                   Index Cond: (c1 = t1.c1)
    
    
    (6 rows)
    
NOTICE:
  • You can specify multiple src parameters in the same condition.
  • If the specified src and dest conditions do not exist or do not meet the parameterized path requirements, this hint does not take effect.
  • If a stream operator exists on the dest scanning operator, this hint does not take effect.

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