简体   繁体   English

按列值对MySQL表进行分区

[英]Partition MySQL table by Column Value

I have a MySQL table with 20 million rows. 我有一个拥有2000万行的MySQL表。 I want to partition to boost speed. 我想分区以提高速度。 The table is in the following format: 该表格式如下:

column    column   column   sector

data      data     data     Capital Goods
data      data     data     Transportation
data      data     data     Technology
data      data     data     Technology
data      data     data     Capital Goods
data      data     data     Finance
data      data     data     Finance

I have applied partitions using the following code: 我使用以下代码应用了分区:

ALTER TABLE technical
PARTITION BY LIST COLUMNS (sector)
(
PARTITION P1 VALUES IN ('Capital Goods'),
PARTITION P2 VALUES IN ('Health Care'),
PARTITION P3 VALUES IN ('Transportation'),
PARTITION P4 VALUES IN ('Finance'),
PARTITION P5 VALUES IN ('Technology'),
PARTITION P6 VALUES IN ('Consumer Services'),
PARTITION P7 VALUES IN ('Energy'),
PARTITION P8 VALUES IN ('Healthcare'),
PARTITION P9 VALUES IN ('Consumer Non-Durables'),
PARTITION P10 VALUES IN ('Consumer Durables')
);

Its all fine so far, but when I look at the table through phpMyAdmin it displays this: 到目前为止一切都很好,但是当我通过phpMyAdmin查看表格时,它会显示: phpMyAdmin MySQL分区

How can sector be less than capital goods ? sector如何低于capital goods

What am I doing wrong? 我究竟做错了什么?

The problem is simply phpMyAdmin reresenting the data in an unusual way. 问题只是phpMyAdmin以不寻常的方式重新呈现数据。 The database is now working as expected and queries such as: 数据库现在按预期工作,查询如下:

SELECT * WHERE ... AND sector = "Energy" 

are running much faster. 跑得快得多。

Thanks to Drew, Uueerdo, Rick James and everybody else for helping me understand this problem. 感谢Drew,Uueerdo,Rick James和其他所有人帮助我理解这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM