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

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive 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.4.2
    iconOceanBase Database
    SQL - V 4.4.2
    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

    Use direct load to accelerate the import of massive data

    Last Updated:2026-04-02 06:23:56  Updated
    Share
    What is on this page
    Background information
    Scenarios
    Technical architecture
    Prerequisites
    Environment preparation
    Data preparation
    Procedure
    Step 1: Create a columnstore table
    Step 2: Execute direct load
    Performance comparison
    References

    folded

    Share

    Background information

    OceanBase Database currently supports three data import methods: Load Data, obloader, and OMS. All of them write data by using the INSERT statement. However, the INSERT operation involves SQL query, transaction processing, and LSM-tree storage. Because OceanBase Database adopts the LSM-tree storage structure, data inserted by using the INSERT statement is first written to a memory table (MemTable), and then stored in the final SSTable through multiple rounds of flushing and compaction. This process consumes a large amount of CPU resources and results in a slow import speed.

    To solve this problem, OceanBase Database introduces the direct load technology. This technology bypasses the intermediate processing steps and directly writes data to the Major SSTable. This technology is not only applicable to data import, but also to SQL operations that involve a large amount of write operations, such as INSERT INTO SELECT.

    ClickBench is an AP benchmark proposed by ClickHouse. You can use this benchmark to test the query performance of OceanBase Database in AP scenarios. Before you run this benchmark, you must import data. The import data step allows you to experience the data import performance of OceanBase Database. You can also use direct load to prepare data for other AP benchmarks such as TPC-H and TPC-DS. This topic describes how to use direct load to accelerate the import of massive data and experience the high performance of OceanBase Database.

    Scenarios

    • Data preparation for AP scenarios: such as ClickHouse Benchmark, TPC-H, and TPC-DS.
    • Acceleration of batch write operations: such as INSERT INTO SELECT.

    You can use direct load to significantly improve the data import efficiency in scenarios where you need to quickly load massive data.

    Technical architecture

    You can import data by using one of the following two paths.

    • Traditional path: The traditional path, indicated by the blue arrow, involves SQL query, transaction processing, and data storage.

    • Direct load path: The direct load path, indicated by the green arrow, mainly involves data type conversion and sorting by primary key (if any), and then writing the sorted data to the Major SSTable. Direct load is a short path that consumes fewer system resources and accelerates the import.

    The following figure shows the two paths.

    1

    Prerequisites

    Environment preparation

    • Environment requirements:

      • An OceanBase Database V4.3 or later cluster has been deployed, and a MySQL-compatible tenant has been created.
      • The resource specifications of the cluster are 16 CPU cores and 32 GB of memory. All steps and test results are based on this configuration.

      For more information about how to deploy an OceanBase Database cluster, see Overview. After the cluster is deployed, you can execute the following SQL statements in the sys tenant to view the cluster and tenant information:

      -- View the cluster information.
      SELECT * FROM GV$OB_SERVERS;
      
      -- View the tenant information.
      SELECT * FROM oceanbase.DBA_OB_TENANTS;
      
    • Permission requirements:

      The created tenant must have the INSERT and SELECT permissions. For more information about the permissions of OceanBase Database, see Permissions in MySQL-compatible mode.

    Data preparation

    Download the test data

    • Go to the ClickHouse website and download the hits dataset.

    • Decompress the data to a specified path, for example, /path/to/hits.tsv.

    Procedure

    Step 1: Create a columnstore table

    • Execute the following statement to create a columnstore table:

      CREATE TABLE hits
      (
        WatchID BIGINT NOT NULL,
        JavaEnable SMALLINT NOT NULL,
        Title TEXT NOT NULL,
        GoodEvent SMALLINT NOT NULL,
        EventTime TIMESTAMP NOT NULL,
        EventDate Date NOT NULL,
        CounterID INTEGER NOT NULL,
        ClientIP INTEGER NOT NULL,
        RegionID INTEGER NOT NULL,
        UserID BIGINT NOT NULL,
        CounterClass SMALLINT NOT NULL,
        OS SMALLINT NOT NULL,
        UserAgent SMALLINT NOT NULL,
        URL TEXT NOT NULL,
        Referer TEXT NOT NULL,
        IsRefresh SMALLINT NOT NULL,
        RefererCategoryID SMALLINT NOT NULL,
        RefererRegionID INTEGER NOT NULL,
        URLCategoryID SMALLINT NOT NULL,
        URLRegionID INTEGER NOT NULL,
        ResolutionWidth SMALLINT NOT NULL,
        ResolutionHeight SMALLINT NOT NULL,
        ResolutionDepth SMALLINT NOT NULL,
        FlashMajor SMALLINT NOT NULL,
        FlashMinor SMALLINT NOT NULL,
        FlashMinor2 TEXT NOT NULL,
        NetMajor SMALLINT NOT NULL,
        NetMinor SMALLINT NOT NULL,
        UserAgentMajor SMALLINT NOT NULL,
        UserAgentMinor VARCHAR(255) NOT NULL,
        CookieEnable SMALLINT NOT NULL,
        JavascriptEnable SMALLINT NOT NULL,
        IsMobile SMALLINT NOT NULL,
        MobilePhone SMALLINT NOT NULL,
        MobilePhoneModel TEXT NOT NULL,
        Params TEXT NOT NULL,
        IPNetworkID INTEGER NOT NULL,
        TraficSourceID SMALLINT NOT NULL,
        SearchEngineID SMALLINT NOT NULL,
        SearchPhrase TEXT NOT NULL,
        AdvEngineID SMALLINT NOT NULL,
        IsArtifical SMALLINT NOT NULL,
        WindowClientWidth SMALLINT NOT NULL,
        WindowClientHeight SMALLINT NOT NULL,
        ClientTimeZone SMALLINT NOT NULL,
        ClientEventTime TIMESTAMP NOT NULL,
        SilverlightVersion1 SMALLINT NOT NULL,
        SilverlightVersion2 SMALLINT NOT NULL,
        SilverlightVersion3 INTEGER NOT NULL,
        SilverlightVersion4 SMALLINT NOT NULL,
        PageCharset TEXT NOT NULL,
        CodeVersion INTEGER NOT NULL,
        IsLink SMALLINT NOT NULL,
        IsDownload SMALLINT NOT NULL,
        IsNotBounce SMALLINT NOT NULL,
        FUniqID BIGINT NOT NULL,
        OriginalURL TEXT NOT NULL,
        HID INTEGER NOT NULL,
        IsOldCounter SMALLINT NOT NULL,
        IsEvent SMALLINT NOT NULL,
        IsParameter SMALLINT NOT NULL,
        DontCountHits SMALLINT NOT NULL,
        WithHash SMALLINT NOT NULL,
        HitColor CHAR NOT NULL,
        LocalEventTime TIMESTAMP NOT NULL,
        Age SMALLINT NOT NULL,
        Sex SMALLINT NOT NULL,
        Income SMALLINT NOT NULL,
        Interests SMALLINT NOT NULL,
        Robotness SMALLINT NOT NULL,
        RemoteIP INTEGER NOT NULL,
        WindowName INTEGER NOT NULL,
        OpenerName INTEGER NOT NULL,
        HistoryLength SMALLINT NOT NULL,
        BrowserLanguage TEXT NOT NULL,
        BrowserCountry TEXT NOT NULL,
        SocialNetwork TEXT NOT NULL,
        SocialAction TEXT NOT NULL,
        HTTPError SMALLINT NOT NULL,
        SendTiming INTEGER NOT NULL,
        DNSTiming INTEGER NOT NULL,
        ConnectTiming INTEGER NOT NULL,
        ResponseStartTiming INTEGER NOT NULL,
        ResponseEndTiming INTEGER NOT NULL,
        FetchTiming INTEGER NOT NULL,
        SocialSourceNetworkID SMALLINT NOT NULL,
        SocialSourcePage TEXT NOT NULL,
        ParamPrice BIGINT NOT NULL,
        ParamOrderID TEXT NOT NULL,
        ParamCurrency TEXT NOT NULL,
        ParamCurrencyID SMALLINT NOT NULL,
        OpenstatServiceName TEXT NOT NULL,
        OpenstatCampaignID TEXT NOT NULL,
        OpenstatAdID TEXT NOT NULL,
        OpenstatSourceID TEXT NOT NULL,
        UTMSource TEXT NOT NULL,
        UTMMedium TEXT NOT NULL,
        UTMCampaign TEXT NOT NULL,
        UTMContent TEXT NOT NULL,
        UTMTerm TEXT NOT NULL,
        FromTag TEXT NOT NULL,
        HasGCLID SMALLINT NOT NULL,
        RefererHash BIGINT NOT NULL,
        URLHash BIGINT NOT NULL,
        CLID INTEGER NOT NULL,
        PRIMARY KEY (CounterID, EventDate, UserID, EventTime, WatchID)
      ) with column group (each column);
      

    Step 2: Execute direct load

    Direct load

    LOAD DATA
    /*+
      query_timeout(10000000000)
      parallel(32)
      direct(true, 0)  -- Enable direct load mode.
    */
    INFILE '/path/to/hits.tsv'
    INTO TABLE hits
    FIELDS TERMINATED BY '\t'
    ENCLOSED BY ''
    ESCAPED BY '';
    

    After the preceding statement is executed, you can view the execution time of direct load.

    Non-direct load

    LOAD DATA
    /*+
      query_timeout(10000000000)
      parallel(32)
    */
    INFILE '/path/to/hits.tsv'
    INTO TABLE hits
    FIELDS TERMINATED BY '\t'
    ENCLOSED BY ''
    ESCAPED BY '';
    

    After the preceding statement is executed, you can view the execution time of non-direct load.

    Performance comparison

    Scenario
    Execution time (seconds)
    Direct load 249
    Non-direct load 767

    Note

    The resource specifications of the cluster are 16 CPU cores and 32 GB of memory. The execution environment may vary, which results in different execution times. The execution times in the preceding table are for reference only.

    Conclusion: Direct load improves the import speed by more than 3 times. It is suitable for scenarios where you need to import massive data, such as preparing TPC-H or TPC-DS test data.

    References

    Overview of direct load

    Previous topic

    Use Spark to process and analyze large volumes of data in OceanBase Database quickly
    Last

    Next topic

    OceanBase MCP Server
    Next
    What is on this page
    Background information
    Scenarios
    Technical architecture
    Prerequisites
    Environment preparation
    Data preparation
    Procedure
    Step 1: Create a columnstore table
    Step 2: Execute direct load
    Performance comparison
    References