sql - Using MySQL Partitioning to speed up concurrent deletes and selects? -


i have mysql innodb table contains 8.5 million rows. table structure looks this:

create table `mydatatable` (   `ext_data_id` int(10) unsigned not null,   `datetime_utc` date not null default '0000-00-00',   `type` varchar(8) not null default '',   `value` decimal(6,2) default null,   primary key (`ext_data_id`,`datetime_utc`,`type`),   key `datetime_utc` (`datetime_utc`) ) engine=innodb default charset=utf8; 

every night, delete expired values table following query:

delete mydatatable datetime_utc < '2013-09-23' 

this query not seem use indizes, , takes quite time run. concurrent updates , selects on same table. these locked then, causing website unresponsive @ time.

i looking various ways speed setup. cam across mysql partitioning , wondering if fit. adding , selecting newer data table , deleting old ones. create partitions based on mod(dayofyear(datetime),4). when delete, delete values partition 1 reading or writing from.

will experience locking setup? partitioning improve query speed , availability in case? or should solution, , if so, one?

since mysql 5.5 use function columns, simplifies partitioning non-integer columns (such datetime_utc).

as performance:

  • dropping partition constant time operation list , range partitioning. speed equivalent of truncate table or rm file, practically independent of size of partition.
  • doing select on partitioned table benefits partition pruning, read partition match search criteria. can speed range scans.

tip:

do not forget add "default" partition, such as

    partition the_last_one values less than(maxvalue) 

in order avoid insert/update statements fail since no partition found insert into.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -