A customer comes in to your store and asks for a list of all the books in the category of medicine, published between the years of 19. This database has tables for each category of books. It searches only the partitions that fit the criteria of the query.Īs the first example below shows, suppose that you have a bookstore and you have a database containing the entire inventory of books in your store. “Pruning” happens when the MySQL optimizer deduces that the rows it needs to access to execute a particular query reside in a limited number of partitions. Improving Performance with Partitioning: Pruning With MySQL, you can use partitioning schemes that are based on dates and times, making your queries more efficient. For example, you might want to segregate a table of store orders by year, quarter, or month. It is natural to want to partition tables according to date and time values. Partitioning addresses some potential problems specific to large tables, such as slow runtimes for maintenance operations (for example, OPTIMIZE and REPAIR) and slow runtime when deleting unnecessary rows. When you split data into logically grouped tables, a query has fewer records to search. The partition plugin now has the value DISABLED. If you do not see the partition plugin with the Status value ACTIVE listed in the output of SHOW PLUGINS, then your version of MySQL does not support partitioning. If the MySQL binary is built with partitioning support, you do not need to take any further action to enable the binary (for example, no special entries are required in your my.cnf file). LINEAR: MySQL also supports linear hashing, which differs from regular hashing in that linear hashing uses a linear powers-of-two algorithm whereas regular hashing employs the modulus of the hashing function’s value.All of these columns are taken into account both for the purpose of placing rows in partitions and for the determination of which partitions are to be checked for matching rows in partition pruning – RANGE COLUMNS and LIST COLUMNS partitioning support the use of non-integer columns (and other data types listed earlier) for defining value ranges or list members.
COLUMNS partitioning enables the use of one or more columns in partitioning keys. COLUMNS: Variants on RANGE and LIST partitioning.KEY: Similar to HASH, except that only one or more columns to be evaluated are supplied, and the MySQL server provides a hashing function.HASH: Operating on column values in rows to be inserted into the table.LIST: As in partitioning by RANGE, each partition must be explicitly defined.RANGE: Ranges should be contiguous but not overlapping, and are defined using the VALUES LESS THAN operator.MySQL supports several types of partitioning: This value determines which partition each record should be stored in, according to the partition definition(s). With the use of RANGE/LIST COLUMNS, the expression can be one or more columns of the following data types: INTs, DATE, DATETIME, CHAR, VARCHAR, BINARY, and VARBINARY.Ĥ.The expression must return NULL or an integer value.The expression can be either an integer column value, or a function acting on one or more column values and returning an integer. The function is selected according to the partitioning type specified by the user, and takes the value of a user-supplied expression.ģ. The division of data is accomplished with a partitioning function, which in MySQL can be a simple matching against a set of ranges or value lists, an internal hashing function, or a linear hashing function.Ģ. The way that MySQL accomplishes this is as follows:ġ. Each partition is stored as a separate unit, much like a table. MySQL partitioning allows you to distribute portions of individual tables across your physical storage, according to rules that you can set largely as needed. Now you have partitioned your belongings into specific boxes. For example, you could have a box labeled “Books” for all your books, a box for “CDs,” a box for “Movies,” and so on. And it would be a very large and heavy box! It would be much better to use several boxes to hold all your items, and to categorize those boxes according to type. It would be very difficult for you to find individual items. However, that would not be very practical. You could put all the things from your living room in one big box. Suppose that you are moving out of your home. The “moving” analogy is being used to portray partitioning. You have now partitioned your belongings!.How about putting items in several smaller boxes, by type?.Do you want to put everything from the living room into one giant box?.