按列值分区MySQL表

按列值分区MySQL表

本文介绍了按列值分区MySQL表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL表有20万行。我想分区提高速度。表格格式如下:

 列列栏目

数据资料b $ b数据数据数据运输
数据数据数据技术
数据数据数据技术
数据数据数据资本商品
数据数据数据财务
数据数据数据财务

我使用以下代码应用了分区:

  ALTER TABLE technical 
分区列表(部门)

分区P1值('大宗商品'),
分区P2 VALUES IN('Health Care'),
PARTITION P3 VALUES IN('Transportation'),
PARTITION P4 VALUES IN('Finance'),
PARTITION P5 VALUES IN ,
PARTITION P6 VALUES IN('Consumer Services'),
PARTITION P7 VALUES IN('Energy'),
PARTITION P8 VALUES IN('Healthcare'),
VALUES IN('Consumer Non Durables'),
PARTITION P10 VALUES IN('Consumer Durables')
);

到目前为止所有都很好,但是当我通过phpMyAdmin查看表时,它显示:



如何部门小于



问题只是phpMyAdmin以不寻常的方式呈现数据。数据库现在按预期工作,并且查询如:

  SELECT * WHERE ... AND sector =Energy

运行得更快。



感谢Drew,Uueerdo,Rick James和其他人帮助我理解这个问题。


I have a MySQL table with 20 million rows. 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:

How can sector be less than capital goods ?

What am I doing wrong?

解决方案

The problem is simply phpMyAdmin reresenting the data in an unusual way. 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.

这篇关于按列值分区MySQL表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:54