Ich habe Tabelle "Elemente". 18 Millionen Datensätze:Partitionierung von Daten mysql
CREATE TABLE IF NOT EXISTS `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`log_id` int(11) NOT NULL,
`res_id` int(11) NOT NULL,
`link` varchar(255) NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`n_date` varchar(255) NOT NULL,
`nd_date` int(11) NOT NULL,
`s_date` int(11) NOT NULL,
`not_date` date NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `link_2` (`link`),
KEY `log_id` (`log_id`),
KEY `res_id` (`res_id`),
KEY `now_date` (`not_date`),
KEY `sql_index` (`res_id`,`id`,`not_date`)
) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=0 AUTO_INCREMENT=18382133 ;
Der Versuch, diese Tabelle ich eine Mini-Kopie davon erstellt partitionieren und Spalte 'not_date' in primären und uniq Tasten sind:
CREATE TABLE IF NOT EXISTS `part_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`log_id` int(11) NOT NULL,
`res_id` int(11) NOT NULL,
`link` varchar(255) NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`n_date` varchar(255) NOT NULL,
`nd_date` int(11) NOT NULL,
`s_date` int(11) NOT NULL,
`not_date` date NOT NULL,
PRIMARY KEY (`not_date`,`id`),
UNIQUE KEY `link_2` (`not_date`,`link`),
KEY `log_id` (`log_id`),
KEY `res_id` (`res_id`),
KEY `now_date` (`not_date`),
KEY `sql_index` (`res_id`,`id`,`not_date`)
) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=0
/*!50100 PARTITION BY RANGE (TO_DAYS(not_date))
(PARTITION p_1 VALUES LESS THAN (735963) ENGINE = Aria,
PARTITION p_2 VALUES LESS THAN (736694) ENGINE = Aria) */ AUTO_INCREMENT=18414661 ;
Dann laufe ich sql_query:
alter table `part_items` PARTITION BY RANGE(TO_DAYS(not_date)) (
PARTITION p_1 VALUES LESS THAN(TO_DAYS('2014-12-31')),
PARTITION p_2 VALUES LESS THAN(TO_DAYS('2016-12-31'))
);
Dann versuche ich Datensätze auszuwählen, die müssen in p_1 und erklären Partitionen zeigen mir, dass die Suche nur in p_1 war. Aber wenn ich Datensätze auswähle, die in p_2 sein müssen, erklären EXPLAIN-Partitionen Full-Scan (p_1, p_2). Was ist falsch in meinem Code? Abfragen:
explain partitions SELECT * FROM `part_items` where content like '%k%' and not_date < '2014-05-12'
explain partitions SELECT * FROM `part_items` where content like '%k%' and not_date > '2015-01-01'
Und noch eine Frage: Ist es möglich, Ansichten zu partitionieren?
der hinzufügen erkläre bitte die Ausgabe – e4c5
Ich habe bearbeiten Frage, erklären dort Ausgabe – Baurzhan
Kann mir jemand helfen? – Baurzhan