溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mysql partition table use to_days bug

發(fā)布時(shí)間:2020-08-10 22:57:05 來源:ITPUB博客 閱讀:161 作者:psufnxk2000 欄目:MySQL數(shù)據(jù)庫
to_days分區(qū)表 bug

CREATE TABLE `aaaaaaaaaa` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `year` int(4) NOT NULL,
  `month` int(2) NOT NULL,
  `day` int(2) NOT NULL,
  `startTime` datetime NOT NULL,
  `endTime` datetime NOT NULL,
  `version` varchar(12) NOT NULL DEFAULT '',
  `source` varchar(12) NOT NULL DEFAULT '',
  `sid` varchar(12) NOT NULL,
  `valid` int(8) NOT NULL,
  `error` int(8) NOT NULL,
  `total` int(8) NOT NULL,
  PRIMARY KEY (`id`,`startTime`,`version`,`source`,`sid`),
  KEY `aaaaaaaaaa_index_startTime` (`startTime`),
  KEY `aaaaaaaaaa_index_endTime` (`endTime`),
  KEY `aaaaaaaaaa_muti_index` (`year`,`month`,`source`),
  KEY `aaaaaaaaaa_index_source` (`source`),
  KEY `month_index` (`month`),
  KEY `year_index` (`year`)
) ENGINE=InnoDB AUTO_INCREMENT=1267666446 DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (to_days(startTime))
(PARTITION p20160405 VALUES LESS THAN (736425) ENGINE = InnoDB,
 PARTITION p20160620 VALUES LESS THAN (736501) ENGINE = InnoDB,
 PARTITION p20160706 VALUES LESS THAN (736517) ENGINE = InnoDB) */
 
 
  執(zhí)行下面的sql,mysql 會(huì)crash
 select sid as sid,source as source,sum(valid) as valid,sum(error) as error from aaaaaaaaaa where startTime>="2016-07-08 10:00:00" 
 
  通過下面的方法可以fix
 alter table aaaaaaaaaa add PARTITION  (partition p_max values less than(maxvalue));
 


另:

CREATE TABLE `aaaaaaaaaa` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `year` int(4) NOT NULL,
  `month` int(2) NOT NULL,
  `day` int(2) NOT NULL,
  `startTime` datetime NOT NULL,
  `endTime` datetime NOT NULL,
  `version` varchar(12) NOT NULL DEFAULT '',
  `source` varchar(12) NOT NULL DEFAULT '',
  `sid` varchar(12) NOT NULL,
  `valid` int(8) NOT NULL,
  `error` int(8) NOT NULL,
  `total` int(8) NOT NULL,
  PRIMARY KEY (`id`,`startTime`,`version`,`source`,`sid`)
  ) ENGINE=InnoDB AUTO_INCREMENT=1267666446 DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (to_days(startTime))
(PARTITION p20160405 VALUES LESS THAN (736425) ENGINE = InnoDB,
 PARTITION p20160620 VALUES LESS THAN (736501) ENGINE = InnoDB,
 PARTITION p20160706 VALUES LESS THAN (736517) ENGINE = InnoDB) */
 
 這樣不會(huì)出現(xiàn)上面的問題
 
 
 
 但如果把starttime列加上索引 ,就會(huì)有這個(gè)問題
 CREATE TABLE `aaaaaaaaaa` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `year` int(4) NOT NULL,
  `month` int(2) NOT NULL,
  `day` int(2) NOT NULL,
  `startTime` datetime NOT NULL,
  `endTime` datetime NOT NULL,
  `version` varchar(12) NOT NULL DEFAULT '',
  `source` varchar(12) NOT NULL DEFAULT '',
  `sid` varchar(12) NOT NULL,
  `valid` int(8) NOT NULL,
  `error` int(8) NOT NULL,
  `total` int(8) NOT NULL,
  PRIMARY KEY (`id`,`startTime`,`version`,`source`,`sid`),
  KEY `aaaaaaaaaa_index_startTime` (`startTime`)
) ENGINE=InnoDB AUTO_INCREMENT=1267666446 DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (to_days(startTime))
(PARTITION p20160405 VALUES LESS THAN (736425) ENGINE = InnoDB,
 PARTITION p20160620 VALUES LESS THAN (736501) ENGINE = InnoDB,
 PARTITION p20160706 VALUES LESS THAN (736517) ENGINE = InnoDB) */
 
 MOS沒有找到相關(guān)的bug
 5.1 5.6 中都沒有這個(gè)問題,5.5.24中有這個(gè)問題
 
轉(zhuǎn)載請(qǐng)注明源出處
QQ 273002188 歡迎一起學(xué)習(xí)
QQ 群 236941212
oracle,mysql,PG 相互交流
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI