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

LIST DEFAULT HASH

Updated on 2025-02-11 GMT+08:00

TaurusDB supports two partition types at the same level: LIST and HASH. Data is first inserted into LIST partitions. Data that does not comply with the LIST partitioning rules is placed in the default partition. If the default partition has multiple partitions, HASH rules are used. LIST DEFAULT HASH partitioned tables are usually used in scenarios where LIST VALUES are unevenly distributed and cannot be fully enumerated.

Prerequisites

  • The kernel version of your TaurusDB instance must be 2.0.54.240600 or later.
  • rds_list_default_partition_enabled has been set to ON.

Constraints

  • You can create one or more DEFAULT partitions.
  • You can create LIST and DEFAULT subpartitions together, but each partition can only have one DEFAULT subpartition.
  • If there is only one DEFAULT partition, subpartitions can be of any types.
  • If there are multiple DEFAULT partitions, only HASH or KEY subpartitions are supported.

Parameters

To enable or disable LIST DEFAULT HASH, configure rds_list_default_partition_enabled on the Parameters page.

Table 1 Parameter description

Parameter

Level

Description

rds_list_default_partition_enabled

Global

Enables or disables LIST DEFAULT HASH.

Value:

  • ON: LIST DEFAULT HASH is enabled.
  • OFF: LIST DEFAULT HASH is disabled.

Creating a LIST DEFAULT HASH Partitioned Table

  • Syntax
    CREATE TABLE [ schema. ]table_name
     table_definition
       PARTITION BY LIST [COLUMNS] (expr)
       SUBPARTITION BY ...
       (list_partition_definition[, ..., list_partition_definition],
        default_partition_definition
       )

    default_partition_definition is:

    PARTITION partition_name DEFAULT [PARTITIONS number]

    The definition of each partition can also contain subpartitions. Subpartitions can also use LIST DEFAULT. The definition is as follows:

    SUBPARTITION subpartition_name DEFAULT
    Table 2 Parameter description

    Parameter

    Description

    table_name

    The name of the table to be created.

    partition_name

    • The name of the partition if there is only one DEFAULT partition. The name must be unique.
    • The prefix of a partition name if there are multiple DEFAULT partitions. The partition name is in the format of partition_name+sequence_number.

    subpartition_name

    The name of the subpartition. The name must be unique within a table. Only one DEFAULT subpartition is supported.

    number

    The number of DEFAULT partitions. You can create multiple DEFAULT partitions based on HASH rules. This parameter is optional. If you do not specify it, a DEFAULT partition is created.

  • Examples

    Create a single DEFAULT partition:

    CREATE TABLE list_default_tbl (
      a INT,
      b INT
    )
    PARTITION BY LIST (a)
    (PARTITION p0 VALUES IN (1,2,3,4,5),
     PARTITION p1 VALUES IN (6,7,8,9,10),
     PARTITION pd DEFAULT);

    Create multiple DEFAULT partitions:

    CREATE TABLE list_default_hash (
      a INT,
      b INT
    )
    PARTITION BY LIST (a)
    (PARTITION p0 VALUES IN (1,2,3,4,5),
     PARTITION p1 VALUES IN (6,7,8,9,10),
     PARTITION pd DEFAULT PARTITIONS 3);

    Use LIST COLUMNS:

    CREATE TABLE t_goods
    (
      country   VARCHAR(30),
      year      VARCHAR(60),
      goods     TEXT
    ) PARTITION BY LIST COLUMNS(country)
    (
      PARTITION p1 VALUES IN ('China'),
      PARTITION p2 VALUES IN ('USA'),
      PARTITION p3 VALUES IN ('Asia'),
      PARTITION p3 VALUES IN ('India'),
      PARTITION p_deft DEFAULT PARTITIONS 5
    );

    Execute the EXPLAIN statement to view partitions:

    EXPLAIN SELECT * FROM list_default_hash;

    The following information is displayed:

    +----+-------------+-------------------+-------------------+------+---------------+------+---------+------+------+----------+-------+
    | id | select_type | table             | partitions        | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra |
    +----+-------------+-------------------+-------------------+------+---------------+------+---------+------+------+----------+-------+
    |  1 | SIMPLE      | list_default_hash | p0,p1,pd0,pd1,pd2 | ALL  | NULL          | NULL | NULL    | NULL |    1 |   100.00 | NULL  |
    +----+-------------+-------------------+-------------------+------+---------------+------+---------+------+------+----------+-------+
    1 row in set (0.04 sec)

    Create a LIST DEFAULT HASH partitioned table which supports LIST DEFAULT subpartitions:

    CREATE TABLE test (a int, b int)
    PARTITION BY RANGE(a)
    SUBPARTITION BY LIST(b) (
    PARTITION part0 VALUES LESS THAN (10)
    ( SUBPARTITION sub0 VALUES IN (1,2,3,4,5),
      SUBPARTITION sub1 DEFAULT),
    PARTITION part1 VALUES LESS THAN (20)
    ( SUBPARTITION sub2 VALUES IN (1,2,3,4,5),
      SUBPARTITION sub3 DEFAULT),
    PARTITION part2 VALUES LESS THAN (30)
    ( SUBPARTITION sub4 VALUES IN (1,2,3,4,5),
      SUBPARTITION sub5 DEFAULT));

    Create a LIST DEFAULT HASH partitioned table which supports only HASH or KEY subpartitions when there are multiple LIST DEFAULT HASH partitions:

    CREATE TABLE list_default_hash_sub (
      a INT,
      b INT
    )
    PARTITION BY LIST (a)
    SUBPARTITION BY HASH (b) SUBPARTITIONS 20
    (PARTITION p0 VALUES IN (1,2,3,4,5),
     PARTITION p1 VALUES IN (6,7,8,9,10),
     PARTITION pd DEFAULT PARTITIONS 3);

Modifying a LIST DEFAULT HASH Partitioned Table

LIST DEFAULT HASH partitions support all the statements for modifying partitioned tables, including ALTER TABLE ADD PARTITION, ALTER TABLE DROP PARTITION, ALTER TABLE REORGANIZE PARTITION, ALTER TABLE TRUNCATE PARTITION, ALTER TABLE EXCHANGE PARTITION, ALTER TABLE OPTIMIZE PARTITION, ALTER TABLE REBUILD PARTITION, ALTER TABLE REPAIR PARTITION, ALTER TABLE ANALYZE PARTITION, and ALTER TABLE CHECK PARTITION. The following shows how to modify a LIST DEFAULT HASH partitioned table by executing the ALTER TABLE ADD PARTITION, ALTER TABLE DROP PARTITION, and ALTER TABLE REORGANIZE PARTITION statements.

  • ALTER TABLE ADD PARTITION
    • ADD DEFAULT PARTITION

      If a partitioned table contains only LIST partitions, run ADD PARTITION to add a DEFAULT partition so that the table becomes a LIST DEFAULT HASH partitioned table.

      ALTER TABLE table_name ADD PARTITION(default_partition_definition)

      Add a DEFAULT partition:

      CREATE TABLE list_tab (
        a INT,
        b INT
      )
      PARTITION BY LIST (a)
      (PARTITION p0 VALUES IN (1,2,3,4,5),
       PARTITION p1 VALUES IN (6,7,8,9,10)
      );
      ALTER TABLE list_tab ADD PARTITION(PARTITION pd DEFAULT);

      Add two DEFAULT partitions:

      CREATE TABLE list_tab (
        a INT,
        b INT
      )
      PARTITION BY LIST (a)
      (PARTITION p0 VALUES IN (1,2,3,4,5),
       PARTITION p1 VALUES IN (6,7,8,9,10)
      );
      ALTER TABLE list_tab ADD PARTITION(PARTITION pd DEFAULT PARTITIONS 2);
    • ADD LIST PARTITION

      You can add WITHOUT VALIDATION to the ALTER TABLE ADD PARTITION statement to add LIST partitions.

      ALTER TABLE table_name ADD PARTITION(
        list_partition_definition[, ..., list_partition_definition])
      WITHOUT VALIDATION

      Add a LIST partition:

      CREATE TABLE list_default_hash (
        a INT,
        b INT
      )
      PARTITION BY LIST (a)
      (PARTITION p0 VALUES IN (1,2,3,4,5),
       PARTITION p1 VALUES IN (6,7,8,9,10),
       PARTITION pd DEFAULT PARTITIONS 3);
      ALTER TABLE list_default_hash ADD PARTITION(
        PARTITION p2 VALUES IN (11,12,13)
      )WITHOUT VALIDATION;

      After the statement is executed, a LIST partition named p2 is added to table list_default_hash. There is no data in p2.

      NOTE:

      If you use WITHOUT VALIDATION to add a LIST partition, you need to manually execute ALTER TABLE ... REBUILD ALL to reallocate data. Otherwise, data will not be reallocated. Data that meets the new partition definition will be still stored in the DEFAULT partition. During a query, all DEFAULT partitions will be marked and not pruned. As a result, the query performance deteriorates. You are advised to use the ALTER TABLE REORGANIZE PARTITION statement to separate some data from the DEFAULT partition and create a new LIST partition.

  • ALTER TABLE DROP PARTITION

    The DROP PARTITION statement deletes all DEFAULT partitions at a time. You cannot execute this statement to delete only some DEFAULT partitions.

    Execute the DROP PARTITION statement to delete all partitions:

    ALTER TABLE list_default_hash DROP PARTITION pd0,pd1,pd2;
    Query OK, 0 rows affected (0.33 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    NOTE:

    When you run the following statement to delete only some DEFAULT partitions, an error will be reported.

    ALTER TABLE list_default_hash DROP PARTITION pd0;

    The error is:

    ERROR 8078 (HY000): DROP PARTITION cannot be used on default partitions of LIST DEFAULT, except once dropping all default partitions

  • ALTER TABLE REORGANIZE PARTITION

    The REORGANIZE PARTITION statement modifies all DEFAULT partitions at a time. You cannot execute this statement to modify only some DEFAULT partitions.

    • Execute the REORGANIZE PARTITION statement to change the number of DEFAULT partitions:
      ALTER TABLE list_default_hash
      REORGANIZE PARTITION
        pd0,pd1
      INTO(
        PARTITION pd DEFAULT PARTITIONS 3);

      After the statement is executed, the number of DEFAULT partitions changes from 2 to 3.

    • Execute the REORGANIZE PARTITION statement to split a LIST partition from a DEFAULT partition:
      ALTER TABLE list_default_hash
      REORGANIZE PARTITION
        pd0,pd1
      INTO (
       PARTITION p2 VALUES IN (20,21),
       PARTITION pd DEFAULT PARTITIONS 2);

      After the statement is executed, a LIST partition named p2 is added to the list_default_hash partitioned table. p2 contains data that meets the VALUES IN (20,21) rule and is separated from the DEFAULT partition.

    • Execute the REORGANIZE PARTITION statement to merge a LIST partition into a DEFAULT partition:
      ALTER TABLE list_default_hash
      REORGANIZE PARTITION
        p2, pd0, pd1
      INTO (
       PARTITION pd DEFAULT PARTITIONS 2);

      After the statement is executed, the LIST partition p2 is merged into the DEFAULT partition.

    • Execute the REORGANIZE PARTITION statement to split some values from a DEFAULT partition and add them to a LIST partition:
      ALTER TABLE list_default
      REORGANIZE partition
        p2, pd0, pd1
      INTO (
        PARTITION p2 VALUES IN (20,21,22,23,24),
        PARTITION pd DEFAULT PARTITIONS 4);

      After the statement is executed, the definition of p2 is changed from PARTITION p2 VALUES IN (20,21) to PARTITION p2 VALUES IN (20,21,22,23,24). Any data that matches the VALUES IN (20,21,22,23,24) rule is then transferred from the DEFAULT partition to p2.

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