分别测量关键分区表和普通表的性能。但是我们找不到分区带来的任何性能改进。查询被修剪。
在 RHEL 4 上使用 MySQL 5.1.47。
表格详细信息:
UserUsage
- 将包含每个日期的用户手机号码和数据使用情况条目。手机号码和日期作为 PRI KEY。
UserProfile
- 查询上一个表并存储每个手机号码的摘要。手机号码PRI KEY。
CREATE TABLE `UserUsage` (
`Msisdn` decimal(20,0) NOT NULL,
`Date` date NOT NULL,
.
.
PRIMARY KEY USING BTREE (`Msisdn`,`Date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY KEY(Msisdn)
PARTITIONS 50;
CREATE TABLE `UserProfile` (
`Msisdn` decimal(20,0) NOT NULL,
.
.
PRIMARY KEY (`Msisdn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY KEY(Msisdn)
PARTITIONS 50;
在perl程序中,第二个表通过查询选择更新,并按第一个表中的日期排序,查询是
select * from UserUsage where Msisdn=number order by Date desc limit 7
[用perl处理数据]
update UserProfile values(....) where Msisdn=number
explain partition for select,显示仅在特定分区中扫描的行。
分区设计或查询是否有问题,因为与普通表相比,分区花费的时间几乎相同或更多?
最佳答案
Is something wrong with partition design or queries as partitioning is taking almost same or more time compared to normal tables?
没有。您对表进行分区,这样您就不必一次备份或重新组织整个表。分区使您可以更好地管理大型表。分区不是性能增强器。
关于optimization - MySQL 分区性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2912035/