What is Range Partitioning
Range partitioning in MySQL allows you to partition the database by defining a specific range; the entries coming within the defined range would be considered in the partition. To understand more precisely the Range partitioning and its use; let us consider this example, create a table of students of the school bus and partitioned them on the basis of their age using the command:
In the above-executed command, we have created three partitions; p0,p1,p2:
- Students of age less than 10 are placed in partition p0
- Students of age less than 15 but greater than 10 are placed in partition p1
- Students between 15-20 are placed in partition p2
To insert the data in this table, use the command:
To display the school_bus_data table:
To display in the form of partition of the table using the command:
In the above output, we can see that the two table rows are placed in partition p0 and p1, and one row is placed in p2 on the basis of the std_age we defined. Moreover, the table also displayed the average row length and data length of each partition.
RANGE partitioning helps you to manage the data more easily as you can sort the data according to a specific range and then utilize it when it is needed. MySQL is the popular RDMS; it allows the feature of the partitions which speed up the execution of the queries in managing the data of the databases. The data is divided into partitions on the basis of some parameters. In this post, we discussed one of these parameters of partition; Range also discussed an example for the better understanding of readers.