OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.1

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.1
    iconOceanBase Database
    SQL - V 4.3.1
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Hints related to joins

    Last Updated:2026-04-15 08:25:15  Updated
    Share
    What is on this page
    USE_MERGE hint
    NO_USE_MERGE hint
    USE_HASH hint
    NO_USE_HASH hint
    USE_NL hint
    NO_USE_NL hint
    USE_BNL hint
    NO_USE_BNL hint

    folded

    Share

    Hints related to joins are USE_MERGE, NO_USE_MERGE, USE_HASH, NO_USE_HASH, USE_NL, NO_USE_NL, USE_BNL, and NO_USE_BNL.

    USE_MERGE hint

    The USE_MERGE hint instructs the optimizer to use a sort-merge join to join each specified table with another row source and use the specified table as the right-side table.

    The syntax of the USE_MERGE hint is as follows:

    /*+ USE_MERGE ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    We recommend that you use the USE_NL and USE_MERG hints with the LEADING or ORDERED hint. If the referenced tables are right-side tables, the optimizer uses these hints. If the referenced tables are left-side tables, the optimizer ignores these hints. The USE_MERGE hint specifies to use the MERGE-JOIN algorithm when the specified table is a right-side table. In OceanBase Database, to use the MERGE-JOIN algorithm, the tables to be joined must have equivalent join conditions. When you join two tables that do not have equivalent conditions, the USE_MERGE hint is invalid.

    Here is an example of the USE_MERGE hint:

    SELECT /*+ USE_MERGE(employees departments) */ *
    FROM employees, departments
    WHERE employees.department_id = departments.department_id;
    

    NO_USE_MERGE hint

    The NO_USE_MERGE hint instructs the optimizer to exclude joins used by the USE_MERGE hint when the optimizer uses the specified table as a right-side table and joins the table with another row source.

    The syntax of the NO_USE_MERGE hint is as follows:

    /*+ NO_USE_MERGE ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    Here is an example of the NO_USE_MERGE hint:

    SELECT /*+ NO_USE_MERGE(e d) */ *
    FROM employees e, departments d
    WHERE e.department_id = d.department_id;
    

    USE_HASH hint

    The USE_HASH hint instructs the optimizer to use the HASH-JOIN algorithm to join each specified table with another row source and use the specified table as the right-side table.

    The syntax of the USE_HASH hint is as follows:

    /*+ USE_HASH ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    Here is an example of the USE_HASH hint:

    SELECT /*+ USE_HASH(l h) */ *
      FROM orders h, order_items l
      WHERE l.order_id = h.order_id
        AND l.order_id > 2400;
    

    NO_USE_HASH hint

    The NO_USE_HASH hint instructs the optimizer to exclude the joins used by the USE_HASH hint when the optimizer uses the specified table as a right-side table and joins the table with another row source.

    The syntax of the NO_USE_HASH hint is as follows:

    /*+ NO_USE_HASH ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    Here is an example of the NO_USE_HASH hint:

    SELECT /*+ NO_USE_HASH(e d) */ *
    FROM employees e, departments d
    WHERE e.department_id = d.department_id;
    

    USE_NL hint

    The USE_NL hint instructs the optimizer to use a nest-loop (NL) join to join each specified table to another row source and use the specified table as a right-side table with the NL join algorithm.

    The syntax of the USE_NL hint is as follows:

    /*+ USE_NL ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    We recommend that you use the USE_NL and USE_MERG hints with the LEADING or ORDERED hint. If the referenced tables are right-side tables, the optimizer uses these hints. If the referenced tables are left-side tables, the optimizer ignores these hints.

    In the following example, a nested loop is forced by using a hint, the orders table is accessed by using a full table scan, and the filter condition l.order_id = h.order_id is applied to each row. For each row that meets the filter condition, order_items is accessed by using the index order_id.

    SELECT /*+ USE_NL(l h) */ h.customer_id, l.unit_price * l.quantity
    FROM orders h, order_items l
    WHERE l.order_id = h.order_id;
    

    NO_USE_NL hint

    The NO_USE_NL hint instructs the optimizer to exclude the nested-loop joins when the optimizer uses the specified table as a right-side table and joins the table with another row source.

    The syntax of the NO_USE_NL hint is as follows:

    /*+ NO_USE_NL ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    Here is an example of the NO_USE_NL hint:

    SELECT /*+ NO_USE_NL(e d) */ *
    FROM employees e, departments d
    WHERE e.department_id = d.department_id;
    

    USE_BNL hint

    The USE_BNL hint instructs the optimizer to use a block-nested loop (BNL) join to join each specified table to another row source and use the specified table as a right-side table with the BNL join algorithm.

    The syntax of the USE_BNL hint is as follows:

    /*+ USE_BNL ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    We recommend that you use the USE_BN hint with the LEADING or ORDERED hint. If the referenced tables are right-side tables, the optimizer uses these hints. If the referenced tables are left-side tables, the optimizer ignores these hints.

    In the following example, the hint forcibly executes the block nested loops, accesses the orders table by table scanning, and applies the filtering conditions l.order_id = h.order_id to each row. For each row that meets the filter condition, order_items is accessed by using the index order_id.

    SELECT /*+ USE_BNL(l h) */ h.customer_id, l.unit_price * l.quantity
    FROM orders h, order_items l
    WHERE l.order_id = h.order_id;
    

    NO_USE_BNL hint

    The NO_USE_BNL hint instructs the optimizer to exclude the joins used by the USE_BNL hint when the optimizer uses the specified table as a right-side table and joins the table to another row resource.

    The syntax of the NO_USE_BNL hint is as follows:

    /*+ NO_USE_BNL ( [ @queryblock ] tablespec [ tablespec ]... ) */
    

    Here is an example of the NO_USE_BNL hint:

    SELECT /*+ NO_USE_BNL(e d) */ *
    FROM employees e, departments d
    WHERE e.department_id = d.department_id;
    

    Previous topic

    Hints related to join orders
    Last

    Next topic

    Hints related to parallel execution
    Next
    What is on this page
    USE_MERGE hint
    NO_USE_MERGE hint
    USE_HASH hint
    NO_USE_HASH hint
    USE_NL hint
    NO_USE_NL hint
    USE_BNL hint
    NO_USE_BNL hint