I have a specific question about the mysql subkey using the hash in the date / datetime column . I partitioned site_id, and now I want to divide by month (1 to 12), so the number of sections is fixed in time (sp_dec, sp_jan, ...)
The structure of the current cut (columns and other sections):
CREATE TABLE IF NOT EXISTS `email` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`sent_date` datetime NOT NULL,
`site_id` tinyint(4) NOT NULL,
PRIMARY KEY (`id`,`site_id`,`sent_date`),
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY LIST (site_id)
SUBPARTITION BY HASH (MONTH(sent_date)) (
PARTITION p0 VALUES IN (1,3,4) (
SUBPARTITION dec0 ENGINE = InnoDB,
SUBPARTITION jan0 ENGINE = InnoDB,
SUBPARTITION feb0 ENGINE = InnoDB,
SUBPARTITION mar0 ENGINE = InnoDB,
SUBPARTITION apr0 ENGINE = InnoDB,
SUBPARTITION may0 ENGINE = InnoDB,
SUBPARTITION jun0 ENGINE = InnoDB,
SUBPARTITION jul0 ENGINE = InnoDB,
SUBPARTITION aug0 ENGINE = InnoDB,
SUBPARTITION sep0 ENGINE = InnoDB,
SUBPARTITION oct0 ENGINE = InnoDB,
SUBPARTITION nov0 ENGINE = InnoDB)
);
I saw that I should not use the MONTH function to trim. Most examples use Range to manage monthly issues, but it is not available in the unit ...
Firstly, I was not able to use datetime, since my_date = '2010-09-27' failed due to the time part, so I need to use between or> = tips. In this case, cropping is no longer applied, so all sections are used!
-, datetime , my_date = '2010-09-27' .
.
EXPLAIN PARTITIONS SELECT * FROM `email` WHERE sent_date >='2010-09-27'
AND sent_date<'2010-09-28';
EXPLAIN PARTITIONS SELECT * FROM `email` WHERE
sent_date BETWEEN '2010-09-20' AND '2010-09-27';
. , .
, ?
:)