I have a MySQL table with 20 million rows. Querying this database is taking too much time. The database is in the format below:
Column Column Column Sector
data data data Retail
data data data Utility
data data data Retail
data data data Insurance
data data data Retail
data data data Agriculture
data data data Agriculture
data data data Retail
I want to be able to partition the database by sector. This should boost speed for queries where the sector is specified. I have tried the following and it does not work. Where am I going wrong?
Alter table 'technical' partition by values in `sector`
https://dev.mysql.com/doc/refman/5.7/en/partitioning-types.html
From those Partitioning Types, I think LIST COLUMNS partitioning would be the best choice for you. Read further details about it from here ..
https://dev.mysql.com/doc/refman/5.7/en/partitioning-columns-list.html
Your code should look like ..
ALTER TABLE technical
PARTITION BY LIST COLUMNS (sector)
(
PARTITION p01 VALUES IN ('Retail'),
PARTITION p02 VALUES IN ('Utility'),
PARTITION p03 VALUES IN ('Insurance'),
PARTITION p04 VALUES IN ('Agriculture')
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.