mysql TO_DAYS 和 FROM_DAYS

时间:2021-08-19 19:10:19
mysql> show create table history\G;
*************************** 1. row ***************************
       Table: history
Create Table: CREATE TABLE `history` (
  `itemid` bigint(20) unsigned NOT NULL,
  `clock` int(11) NOT NULL DEFAULT '0',
  `value` double(16,4) NOT NULL DEFAULT '0.0000',
  `ns` int(11) NOT NULL DEFAULT '0',
  KEY `history_1` (`itemid`,`clock`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (clock)
(PARTITION p20161201 VALUES LESS THAN (1480608000) ENGINE = InnoDB,
 PARTITION p20161202 VALUES LESS THAN (1480694400) ENGINE = InnoDB,
 PARTITION p20161203 VALUES LESS THAN (1480780800) ENGINE = InnoDB,
 PARTITION p20171227 VALUES LESS THAN (1514390400) ENGINE = InnoDB,
 PARTITION p20171228 VALUES LESS THAN (1514476800) ENGINE = InnoDB,
 PARTITION p20171229 VALUES LESS THAN (1514563200) ENGINE = InnoDB,
 PARTITION p20171230 VALUES LESS THAN (1514649600) ENGINE = InnoDB,
 PARTITION p20171231 VALUES LESS THAN (1514736000) ENGINE = InnoDB) */
1 row in set (0.01 sec)

ERROR: 
No query specified


mysql> mysql> explain select * from history partition(p20161220) where itemid=27371;
+----+-------------+---------+------+---------------+-----------+---------+-------+------+-------------+
| id | select_type | table   | type | possible_keys | key       | key_len | ref   | rows | Extra       |
+----+-------------+---------+------+---------------+-----------+---------+-------+------+-------------+
|  1 | SIMPLE      | history | ref  | history_1     | history_1 | 8       | const | 1439 | Using where |
+----+-------------+---------+------+---------------+-----------+---------+-------+------+-------------+
1 row in set (0.00 sec)


mysql> mysql> explain select * from history  where itemid=27371;
+----+-------------+---------+------+---------------+-----------+---------+-------+-------+-------------+
| id | select_type | table   | type | possible_keys | key       | key_len | ref   | rows  | Extra       |
+----+-------------+---------+------+---------------+-----------+---------+-------+-------+-------------+
|  1 | SIMPLE      | history | ref  | history_1     | history_1 | 8       | const | 18021 | Using where |
+----+-------------+---------+------+---------------+-----------+---------+-------+-------+-------------+
1 row in set (0.00 sec)



mysql> show create  table ClientActionTrack\G;
*************************** 1. row ***************************
       Table: ClientActionTrack
Create Table: CREATE TABLE `ClientActionTrack` (
  `sn` bigint(20) NOT NULL AUTO_INCREMENT,
  `clientSn` int(11) DEFAULT NULL,
  `ip` varchar(32) DEFAULT NULL,
  `url` varchar(1000) DEFAULT NULL COMMENT 'request url',
  `httpMethod` varchar(100) DEFAULT NULL COMMENT 'http method',
  `requestParams` text COMMENT '请求参数',
  `requestHeader` varchar(2000) DEFAULT NULL COMMENT '请求头信息',
  `pageUrl` varchar(500) DEFAULT NULL COMMENT '页面Url',
  `sessionId` varchar(100) DEFAULT NULL COMMENT 'session的Id',
  `startTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '访问开始时间',
  `completeTime` datetime DEFAULT NULL COMMENT '访问完成时间',
  PRIMARY KEY (`sn`,`startTime`)
) ENGINE=InnoDB AUTO_INCREMENT=10251622 DEFAULT CHARSET=utf8 COMMENT='用户访问记录表'
/*!50100 PARTITION BY RANGE (TO_DAYS(startTime))
(PARTITION p20151124 VALUES LESS THAN (736292) ENGINE = InnoDB,
 PARTITION p20151125 VALUES LESS THAN (736293) ENGINE = InnoDB,
 PARTITION p20151126 VALUES LESS THAN (736294) ENGINE = InnoDB,
 PARTITION p20151127 VALUES LESS THAN (736295) ENGINE = InnoDB,
 PARTITION p20151128 VALUES LESS THAN (736296) ENGINE = InnoDB,
 PARTITION p20151129 VALUES LESS THAN (736297) ENGINE = InnoDB,
 PARTITION p20151130 VALUES LESS THAN (736298) ENGINE = InnoDB,
 PARTITION p20151201 VALUES LESS THAN (736299) ENGINE = InnoDB,
 PARTITION p20151202 VALUES LESS THAN (736300) ENGINE = InnoDB,
 PARTITION p20151203 VALUES LESS THAN (736301) ENGINE = InnoDB,
 PARTITION p20151204 VALUES LESS THAN (736302) ENGINE = InnoDB,
 PARTITION p20151205 VALUES LESS THAN (736303) ENGINE = InnoDB,
 PARTITION p20151206 VALUES LESS THAN (736304) ENGINE = InnoDB,
 PARTITION p20151207 VALUES LESS THAN (736305) ENGINE = InnoDB,
 PARTITION p20151208 VALUES LESS THAN (736306) ENGINE = InnoDB,
 PARTITION p20151209 VALUES LESS THAN (736307) ENGINE = InnoDB,
 PARTITION p20151210 VALUES LESS THAN (736308) ENGINE = InnoDB,
 PARTITION p20151211 VALUES LESS THAN (736309) ENGINE = InnoDB,
 PARTITION p20151212 VALUES LESS THAN (736310) ENGINE = InnoDB,
 PARTITION p20151213 VALUES LESS THAN (736311) ENGINE = InnoDB,
 PARTITION p20151214 VALUES LESS THAN (736312) ENGINE = InnoDB,
 PARTITION p20151215 VALUES LESS THAN (736313) ENGINE = InnoDB,
 PARTITION p20151216 VALUES LESS THAN (736314) ENGINE = InnoDB,
 PARTITION p20151217 VALUES LESS THAN (736315) ENGINE = InnoDB,
 PARTITION p20151218 VALUES LESS THAN (736316) ENGINE = InnoDB,
 PARTITION p20151219 VALUES LESS THAN (736317) ENGINE = InnoDB,
 PARTITION p20151220 VALUES LESS THAN (736318) ENGINE = InnoDB,
 PARTITION p20151221 VALUES LESS THAN (736319) ENGINE = InnoDB,
 PARTITION p20151222 VALUES LESS THAN (736320) ENGINE = InnoDB,
 PARTITION p20151223 VALUES LESS THAN (736321) ENGINE = InnoDB,
 PARTITION p20151224 VALUES LESS THAN (736322) ENGINE = InnoDB,
 PARTITION p20151225 VALUES LESS THAN (736323) ENGINE = InnoDB,
 PARTITION p20151226 VALUES LESS THAN (736324) ENGINE = InnoDB,
 PARTITION p20151227 VALUES LESS THAN (736325) ENGINE = InnoDB,
 PARTITION p20151228 VALUES LESS THAN (736326) ENGINE = InnoDB,
 PARTITION p20151229 VALUES LESS THAN (736327) ENGINE = InnoDB,
 PARTITION p20151230 VALUES LESS THAN (736328) ENGINE = InnoDB,
 PARTITION p20151231 VALUES LESS THAN (736329) ENGINE = InnoDB,
 PARTITION p20160101 VALUES LESS THAN (736330) ENGINE = InnoDB,
 PARTITION p20160102 VALUES LESS THAN (736331) ENGINE = InnoDB,
 PARTITION p20160103 VALUES LESS THAN (736332) ENGINE = InnoDB,
 PARTITION p20160104 VALUES LESS THAN (736333) ENGINE = InnoDB,
 PARTITION p20160105 VALUES LESS THAN (736334) ENGINE = InnoDB,
 PARTITION p20160106 VALUES LESS THAN (736335) ENGINE = InnoDB,
 PARTITION p20160107 VALUES LESS THAN (736336) ENGINE = InnoDB,
 PARTITION p20160108 VALUES LESS THAN (736337) ENGINE = InnoDB,
 PARTITION p20160109 VALUES LESS THAN (736338) ENGINE = InnoDB,
 PARTITION p20160110 VALUES LESS THAN (736339) ENGINE = InnoDB,
 PARTITION p20160111 VALUES LESS THAN (736340) ENGINE = InnoDB,
 PARTITION p20160112 VALUES LESS THAN (736341) ENGINE = InnoDB,
 PARTITION p20160113 VALUES LESS THAN (736342) ENGINE = InnoDB,
 PARTITION p20160114 VALUES LESS THAN (736343) ENGINE = InnoDB,
 PARTITION p20160115 VALUES LESS THAN (736344) ENGINE = InnoDB,
 PARTITION p20160116 VALUES LESS THAN (736345) ENGINE = InnoDB,
 PARTITION p20160117 VALUES LESS THAN (736346) ENGINE = InnoDB,
 PARTITION p20160118 VALUES LESS THAN (736347) ENGINE = InnoDB,
 PARTITION p20160119 VALUES LESS THAN (736348) ENGINE = InnoDB,
 PARTITION p20160120 VALUES LESS THAN (736349) ENGINE = InnoDB,
 PARTITION p20160121 VALUES LESS THAN (736350) ENGINE = InnoDB,
 PARTITION p20160122 VALUES LESS THAN (736351) ENGINE = InnoDB,
 PARTITION p20160123 VALUES LESS THAN (736352) ENGINE = InnoDB,
 PARTITION p20160124 VALUES LESS THAN (736353) ENGINE = InnoDB,
 PARTITION p20160125 VALUES LESS THAN (736354) ENGINE = InnoDB,
 PARTITION p20160126 VALUES LESS THAN (736355) ENGINE = InnoDB,
 PARTITION p20160127 VALUES LESS THAN (736356) ENGINE = InnoDB,
 PARTITION p20160128 VALUES LESS THAN (736357) ENGINE = InnoDB,
 PARTITION p20160129 VALUES LESS THAN (736358) ENGINE = InnoDB,
 PARTITION p20160130 VALUES LESS THAN (736359) ENGINE = InnoDB,
 PARTITION p20160131 VALUES LESS THAN (736360) ENGINE = InnoDB,
 PARTITION p20160201 VALUES LESS THAN (736361) ENGINE = InnoDB,
 PARTITION p20160202 VALUES LESS THAN (736362) ENGINE = InnoDB,
 PARTITION p20160203 VALUES LESS THAN (736363) ENGINE = InnoDB,
 PARTITION p20160204 VALUES LESS THAN (736364) ENGINE = InnoDB,
 PARTITION p20160205 VALUES LESS THAN (736365) ENGINE = InnoDB,
 PARTITION p20160206 VALUES LESS THAN (736366) ENGINE = InnoDB,
 PARTITION p20160207 VALUES LESS THAN (736367) ENGINE = InnoDB,
 PARTITION p20160208 VALUES LESS THAN (736368) ENGINE = InnoDB,
 PARTITION p20160209 VALUES LESS THAN (736369) ENGINE = InnoDB,
 PARTITION p20160210 VALUES LESS THAN (736370) ENGINE = InnoDB,
 PARTITION p20160211 VALUES LESS THAN (736371) ENGINE = InnoDB,
 PARTITION p20160212 VALUES LESS THAN (736372) ENGINE = InnoDB,
 PARTITION p20160213 VALUES LESS THAN (736373) ENGINE = InnoDB,
 PARTITION p20160214 VALUES LESS THAN (736374) ENGINE = InnoDB,
 PARTITION p20160215 VALUES LESS THAN (736375) ENGINE = InnoDB,
 PARTITION p20160216 VALUES LESS THAN (736376) ENGINE = InnoDB,
 PARTITION p20160217 VALUES LESS THAN (736377) ENGINE = InnoDB,
 PARTITION p20160218 VALUES LESS THAN (736378) ENGINE = InnoDB,
 PARTITION p20160219 VALUES LESS THAN (736379) ENGINE = InnoDB,
 PARTITION p20160220 VALUES LESS THAN (736380) ENGINE = InnoDB,
 PARTITION p20160221 VALUES LESS THAN (736381) ENGINE = InnoDB,
 PARTITION p20160222 VALUES LESS THAN (736382) ENGINE = InnoDB,
 PARTITION p20160223 VALUES LESS THAN (736383) ENGINE = InnoDB,
 PARTITION p20160224 VALUES LESS THAN (736384) ENGINE = InnoDB,
 PARTITION p20160225 VALUES LESS THAN (736385) ENGINE = InnoDB,
 PARTITION p20160226 VALUES LESS THAN (736386) ENGINE = InnoDB,
 PARTITION p20160227 VALUES LESS THAN (736387) ENGINE = InnoDB,
 PARTITION p20160228 VALUES LESS THAN (736388) ENGINE = InnoDB,
 PARTITION p20160229 VALUES LESS THAN (736389) ENGINE = InnoDB,
 PARTITION p20160301 VALUES LESS THAN (736390) ENGINE = InnoDB,
 PARTITION p20160302 VALUES LESS THAN (736391) ENGINE = InnoDB,
 PARTITION p20160303 VALUES LESS THAN (736392) ENGINE = InnoDB,
 PARTITION p20160304 VALUES LESS THAN (736393) ENGINE = InnoDB,
 PARTITION p20160305 VALUES LESS THAN (736394) ENGINE = InnoDB,
 PARTITION p20160306 VALUES LESS THAN (736395) ENGINE = InnoDB,
 PARTITION p20160307 VALUES LESS THAN (736396) ENGINE = InnoDB,
 PARTITION p20160308 VALUES LESS THAN (736397) ENGINE = InnoDB,
 PARTITION p20160309 VALUES LESS THAN (736398) ENGINE = InnoDB,
 PARTITION p20160310 VALUES LESS THAN (736399) ENGINE = InnoDB,
 PARTITION p20160311 VALUES LESS THAN (736400) ENGINE = InnoDB,
 PARTITION p20160312 VALUES LESS THAN (736401) ENGINE = InnoDB,
 PARTITION p20160313 VALUES LESS THAN (736402) ENGINE = InnoDB,
 PARTITION p20160314 VALUES LESS THAN (736403) ENGINE = InnoDB,
 PARTITION p20160315 VALUES LESS THAN (736404) ENGINE = InnoDB,
 PARTITION p20160316 VALUES LESS THAN (736405) ENGINE = InnoDB,
 PARTITION p20160317 VALUES LESS THAN (736406) ENGINE = InnoDB,
 PARTITION p20160318 VALUES LESS THAN (736407) ENGINE = InnoDB,
 PARTITION p20160319 VALUES LESS THAN (736408) ENGINE = InnoDB,
 PARTITION p20160320 VALUES LESS THAN (736409) ENGINE = InnoDB,
 PARTITION p20160321 VALUES LESS THAN (736410) ENGINE = InnoDB,
 PARTITION p20160322 VALUES LESS THAN (736411) ENGINE = InnoDB,
 PARTITION p20160323 VALUES LESS THAN (736412) ENGINE = InnoDB,
 PARTITION p20160324 VALUES LESS THAN (736413) ENGINE = InnoDB,
 PARTITION p20160325 VALUES LESS THAN (736414) ENGINE = InnoDB,
 PARTITION p20160326 VALUES LESS THAN (736415) ENGINE = InnoDB,
 PARTITION p20160327 VALUES LESS THAN (736416) ENGINE = InnoDB,
 PARTITION p20160328 VALUES LESS THAN (736417) ENGINE = InnoDB,
 PARTITION p20160329 VALUES LESS THAN (736418) ENGINE = InnoDB,
 PARTITION p20160330 VALUES LESS THAN (736419) ENGINE = InnoDB,
 PARTITION p20160331 VALUES LESS THAN (736420) ENGINE = InnoDB,
 PARTITION p20160401 VALUES LESS THAN (736421) ENGINE = InnoDB,
 PARTITION p20160402 VALUES LESS THAN (736422) ENGINE = InnoDB,
 PARTITION p20160403 VALUES LESS THAN (736423) ENGINE = InnoDB,
 PARTITION p20160404 VALUES LESS THAN (736424) ENGINE = InnoDB,
 PARTITION p20160405 VALUES LESS THAN (736425) ENGINE = InnoDB,
 PARTITION p20160406 VALUES LESS THAN (736426) ENGINE = InnoDB,
 PARTITION p20160407 VALUES LESS THAN (736427) ENGINE = InnoDB,
 PARTITION p20160408 VALUES LESS THAN (736428) ENGINE = InnoDB,
 PARTITION p20160409 VALUES LESS THAN (736429) ENGINE = InnoDB,
 PARTITION p20160410 VALUES LESS THAN (736430) ENGINE = InnoDB,
 PARTITION p20160411 VALUES LESS THAN (736431) ENGINE = InnoDB,
 PARTITION p20160412 VALUES LESS THAN (736432) ENGINE = InnoDB,
 PARTITION p20160413 VALUES LESS THAN (736433) ENGINE = InnoDB,
 PARTITION p20160414 VALUES LESS THAN (736434) ENGINE = InnoDB,
 PARTITION p20160415 VALUES LESS THAN (736435) ENGINE = InnoDB,
 PARTITION p20160416 VALUES LESS THAN (736436) ENGINE = InnoDB,
 PARTITION p20160417 VALUES LESS THAN (736437) ENGINE = InnoDB,
 PARTITION p20160418 VALUES LESS THAN (736438) ENGINE = InnoDB,
 PARTITION p20160419 VALUES LESS THAN (736439) ENGINE = InnoDB,
 PARTITION p20160420 VALUES LESS THAN (736440) ENGINE = InnoDB,
 PARTITION p20160421 VALUES LESS THAN (736441) ENGINE = InnoDB,
 PARTITION p20160422 VALUES LESS THAN (736442) ENGINE = InnoDB,
 PARTITION p20160423 VALUES LESS THAN (736443) ENGINE = InnoDB,
 PARTITION p20160424 VALUES LESS THAN (736444) ENGINE = InnoDB,
 PARTITION p20160425 VALUES LESS THAN (736445) ENGINE = InnoDB,
 PARTITION p20160426 VALUES LESS THAN (736446) ENGINE = InnoDB,
 PARTITION p20160427 VALUES LESS THAN (736447) ENGINE = InnoDB,
 PARTITION p20160428 VALUES LESS THAN (736448) ENGINE = InnoDB,
 PARTITION p20160429 VALUES LESS THAN (736449) ENGINE = InnoDB,
 PARTITION p20160430 VALUES LESS THAN (736450) ENGINE = InnoDB,
 PARTITION p20160501 VALUES LESS THAN (736451) ENGINE = InnoDB,
 PARTITION p20160502 VALUES LESS THAN (736452) ENGINE = InnoDB,
 PARTITION p20160503 VALUES LESS THAN (736453) ENGINE = InnoDB,
 PARTITION p20160504 VALUES LESS THAN (736454) ENGINE = InnoDB,
 PARTITION p20160505 VALUES LESS THAN (736455) ENGINE = InnoDB,
 PARTITION p20160506 VALUES LESS THAN (736456) ENGINE = InnoDB,
 PARTITION p20160507 VALUES LESS THAN (736457) ENGINE = InnoDB,
 PARTITION p20160508 VALUES LESS THAN (736458) ENGINE = InnoDB,
 PARTITION p20160509 VALUES LESS THAN (736459) ENGINE = InnoDB,
 PARTITION p20160510 VALUES LESS THAN (736460) ENGINE = InnoDB,
 PARTITION p20160511 VALUES LESS THAN (736461) ENGINE = InnoDB,
 PARTITION p20160512 VALUES LESS THAN (736462) ENGINE = InnoDB,
 PARTITION p20160513 VALUES LESS THAN (736463) ENGINE = InnoDB,
 PARTITION p20160514 VALUES LESS THAN (736464) ENGINE = InnoDB,
 PARTITION p20160515 VALUES LESS THAN (736465) ENGINE = InnoDB,
 PARTITION p20160516 VALUES LESS THAN (736466) ENGINE = InnoDB,
 PARTITION p20160517 VALUES LESS THAN (736467) ENGINE = InnoDB,
 PARTITION p20160518 VALUES LESS THAN (736468) ENGINE = InnoDB,
 PARTITION p20160519 VALUES LESS THAN (736469) ENGINE = InnoDB,
 PARTITION p20160520 VALUES LESS THAN (736470) ENGINE = InnoDB,
 PARTITION p20160521 VALUES LESS THAN (736471) ENGINE = InnoDB,
 PARTITION p20160522 VALUES LESS THAN (736472) ENGINE = InnoDB,
 PARTITION p20160523 VALUES LESS THAN (736473) ENGINE = InnoDB,
 PARTITION p20160524 VALUES LESS THAN (736474) ENGINE = InnoDB,
 PARTITION p20160525 VALUES LESS THAN (736475) ENGINE = InnoDB,
 PARTITION p20160526 VALUES LESS THAN (736476) ENGINE = InnoDB,
 PARTITION p20160527 VALUES LESS THAN (736477) ENGINE = InnoDB,
 PARTITION p20160528 VALUES LESS THAN (736478) ENGINE = InnoDB,
 PARTITION p20160529 VALUES LESS THAN (736479) ENGINE = InnoDB,
 PARTITION p20160530 VALUES LESS THAN (736480) ENGINE = InnoDB,
 PARTITION p20160531 VALUES LESS THAN (736481) ENGINE = InnoDB,
 PARTITION p20160601 VALUES LESS THAN (736482) ENGINE = InnoDB,
 PARTITION p20160602 VALUES LESS THAN (736483) ENGINE = InnoDB,
 PARTITION p20160603 VALUES LESS THAN (736484) ENGINE = InnoDB,
 PARTITION p20160604 VALUES LESS THAN (736485) ENGINE = InnoDB,
 PARTITION p20160605 VALUES LESS THAN (736486) ENGINE = InnoDB,
 PARTITION p20160606 VALUES LESS THAN (736487) ENGINE = InnoDB,
 PARTITION p20160607 VALUES LESS THAN (736488) ENGINE = InnoDB,
 PARTITION p20160608 VALUES LESS THAN (736489) ENGINE = InnoDB,
 PARTITION p20160609 VALUES LESS THAN (736490) ENGINE = InnoDB,
 PARTITION p20160610 VALUES LESS THAN (736491) ENGINE = InnoDB,
 PARTITION p20160611 VALUES LESS THAN (736492) ENGINE = InnoDB,
 PARTITION p20160612 VALUES LESS THAN (736493) ENGINE = InnoDB,
 PARTITION p20160613 VALUES LESS THAN (736494) ENGINE = InnoDB,
 PARTITION p20160614 VALUES LESS THAN (736495) ENGINE = InnoDB,
 PARTITION p20160615 VALUES LESS THAN (736496) ENGINE = InnoDB,
 PARTITION p20160616 VALUES LESS THAN (736497) ENGINE = InnoDB,
 PARTITION p20160617 VALUES LESS THAN (736498) ENGINE = InnoDB,
 PARTITION p20160618 VALUES LESS THAN (736499) ENGINE = InnoDB,
 PARTITION p20160619 VALUES LESS THAN (736500) ENGINE = InnoDB,
 PARTITION p20160620 VALUES LESS THAN (736501) ENGINE = InnoDB,
 PARTITION p20160621 VALUES LESS THAN (736502) ENGINE = InnoDB,
 PARTITION p20160622 VALUES LESS THAN (736503) ENGINE = InnoDB,
 PARTITION p20160623 VALUES LESS THAN (736504) ENGINE = InnoDB,
 PARTITION p20160624 VALUES LESS THAN (736505) ENGINE = InnoDB,
 PARTITION p20160625 VALUES LESS THAN (736506) ENGINE = InnoDB,
 PARTITION p20160626 VALUES LESS THAN (736507) ENGINE = InnoDB,
 PARTITION p20160627 VALUES LESS THAN (736508) ENGINE = InnoDB,
 PARTITION p20160628 VALUES LESS THAN (736509) ENGINE = InnoDB,
 PARTITION p20160629 VALUES LESS THAN (736510) ENGINE = InnoDB,
 PARTITION p20160630 VALUES LESS THAN (736511) ENGINE = InnoDB,
 PARTITION p20160701 VALUES LESS THAN (736512) ENGINE = InnoDB,
 PARTITION p20160702 VALUES LESS THAN (736513) ENGINE = InnoDB,
 PARTITION p20160703 VALUES LESS THAN (736514) ENGINE = InnoDB,
 PARTITION p20160704 VALUES LESS THAN (736515) ENGINE = InnoDB,
 PARTITION p20160705 VALUES LESS THAN (736516) ENGINE = InnoDB,
 PARTITION p20160706 VALUES LESS THAN (736517) ENGINE = InnoDB,
 PARTITION p20160707 VALUES LESS THAN (736518) ENGINE = InnoDB,
 PARTITION p20160708 VALUES LESS THAN (736519) ENGINE = InnoDB,
 PARTITION p20160709 VALUES LESS THAN (736520) ENGINE = InnoDB,
 PARTITION p20160710 VALUES LESS THAN (736521) ENGINE = InnoDB,
 PARTITION p20160711 VALUES LESS THAN (736522) ENGINE = InnoDB,
 PARTITION p20160712 VALUES LESS THAN (736523) ENGINE = InnoDB,
 PARTITION p20160713 VALUES LESS THAN (736524) ENGINE = InnoDB,
 PARTITION p20160714 VALUES LESS THAN (736525) ENGINE = InnoDB,
 PARTITION p20160715 VALUES LESS THAN (736526) ENGINE = InnoDB,
 PARTITION p20160716 VALUES LESS THAN (736527) ENGINE = InnoDB,
 PARTITION p20160717 VALUES LESS THAN (736528) ENGINE = InnoDB,
 PARTITION p20160718 VALUES LESS THAN (736529) ENGINE = InnoDB,
 PARTITION p20160719 VALUES LESS THAN (736530) ENGINE = InnoDB,
 PARTITION p20160720 VALUES LESS THAN (736531) ENGINE = InnoDB,
 PARTITION p20160721 VALUES LESS THAN (736532) ENGINE = InnoDB,
 PARTITION p20160722 VALUES LESS THAN (736533) ENGINE = InnoDB,
 PARTITION p20160723 VALUES LESS THAN (736534) ENGINE = InnoDB,
 PARTITION p20160724 VALUES LESS THAN (736535) ENGINE = InnoDB,
 PARTITION p20160725 VALUES LESS THAN (736536) ENGINE = InnoDB,
 PARTITION p20160726 VALUES LESS THAN (736537) ENGINE = InnoDB,
 PARTITION p20160727 VALUES LESS THAN (736538) ENGINE = InnoDB,
 PARTITION p20160728 VALUES LESS THAN (736539) ENGINE = InnoDB,
 PARTITION p20160729 VALUES LESS THAN (736540) ENGINE = InnoDB,
 PARTITION p20160730 VALUES LESS THAN (736541) ENGINE = InnoDB,
 PARTITION p20160731 VALUES LESS THAN (736542) ENGINE = InnoDB,
 PARTITION p20160801 VALUES LESS THAN (736543) ENGINE = InnoDB,
 PARTITION p20160802 VALUES LESS THAN (736544) ENGINE = InnoDB,
 PARTITION p20160803 VALUES LESS THAN (736545) ENGINE = InnoDB,
 PARTITION p20160804 VALUES LESS THAN (736546) ENGINE = InnoDB,
 PARTITION p20160805 VALUES LESS THAN (736547) ENGINE = InnoDB,
 PARTITION p20160806 VALUES LESS THAN (736548) ENGINE = InnoDB,
 PARTITION p20160807 VALUES LESS THAN (736549) ENGINE = InnoDB,
 PARTITION p20160808 VALUES LESS THAN (736550) ENGINE = InnoDB,
 PARTITION p20160809 VALUES LESS THAN (736551) ENGINE = InnoDB,
 PARTITION p20160810 VALUES LESS THAN (736552) ENGINE = InnoDB,
 PARTITION p20160811 VALUES LESS THAN (736553) ENGINE = InnoDB,
 PARTITION p20160812 VALUES LESS THAN (736554) ENGINE = InnoDB,
 PARTITION p20160813 VALUES LESS THAN (736555) ENGINE = InnoDB,
 PARTITION p20160814 VALUES LESS THAN (736556) ENGINE = InnoDB,
 PARTITION p20160815 VALUES LESS THAN (736557) ENGINE = InnoDB,
 PARTITION p20160816 VALUES LESS THAN (736558) ENGINE = InnoDB,
 PARTITION p20160817 VALUES LESS THAN (736559) ENGINE = InnoDB,
 PARTITION p20160818 VALUES LESS THAN (736560) ENGINE = InnoDB,
 PARTITION p20160819 VALUES LESS THAN (736561) ENGINE = InnoDB,
 PARTITION p20160820 VALUES LESS THAN (736562) ENGINE = InnoDB,
 PARTITION p20160821 VALUES LESS THAN (736563) ENGINE = InnoDB,
 PARTITION p20160822 VALUES LESS THAN (736564) ENGINE = InnoDB,
 PARTITION p20160823 VALUES LESS THAN (736565) ENGINE = InnoDB,
 PARTITION p20160824 VALUES LESS THAN (736566) ENGINE = InnoDB,
 PARTITION p20160825 VALUES LESS THAN (736567) ENGINE = InnoDB,
 PARTITION p20160826 VALUES LESS THAN (736568) ENGINE = InnoDB,
 PARTITION p20160827 VALUES LESS THAN (736569) ENGINE = InnoDB,
 PARTITION p20160828 VALUES LESS THAN (736570) ENGINE = InnoDB,
 PARTITION p20160829 VALUES LESS THAN (736571) ENGINE = InnoDB,
 PARTITION p20160830 VALUES LESS THAN (736572) ENGINE = InnoDB,
 PARTITION p20160831 VALUES LESS THAN (736573) ENGINE = InnoDB,
 PARTITION p20160901 VALUES LESS THAN (736574) ENGINE = InnoDB,
 PARTITION p20160902 VALUES LESS THAN (736575) ENGINE = InnoDB,
 PARTITION p20160903 VALUES LESS THAN (736576) ENGINE = InnoDB,
 PARTITION p20160904 VALUES LESS THAN (736577) ENGINE = InnoDB,
 PARTITION p20160905 VALUES LESS THAN (736578) ENGINE = InnoDB,
 PARTITION p20160906 VALUES LESS THAN (736579) ENGINE = InnoDB,
 PARTITION p20160907 VALUES LESS THAN (736580) ENGINE = InnoDB,
 PARTITION p20160908 VALUES LESS THAN (736581) ENGINE = InnoDB,
 PARTITION p20160909 VALUES LESS THAN (736582) ENGINE = InnoDB,
 PARTITION p20160910 VALUES LESS THAN (736583) ENGINE = InnoDB,
 PARTITION p20160911 VALUES LESS THAN (736584) ENGINE = InnoDB,
 PARTITION p20160912 VALUES LESS THAN (736585) ENGINE = InnoDB,
 PARTITION p20160913 VALUES LESS THAN (736586) ENGINE = InnoDB,
 PARTITION p20160914 VALUES LESS THAN (736587) ENGINE = InnoDB,
 PARTITION p20160915 VALUES LESS THAN (736588) ENGINE = InnoDB,
 PARTITION p20160916 VALUES LESS THAN (736589) ENGINE = InnoDB,
 PARTITION p20160917 VALUES LESS THAN (736590) ENGINE = InnoDB,
 PARTITION p20160918 VALUES LESS THAN (736591) ENGINE = InnoDB,
 PARTITION p20160919 VALUES LESS THAN (736592) ENGINE = InnoDB,
 PARTITION p20160920 VALUES LESS THAN (736593) ENGINE = InnoDB,
 PARTITION p20160921 VALUES LESS THAN (736594) ENGINE = InnoDB,
 PARTITION p20160922 VALUES LESS THAN (736595) ENGINE = InnoDB,
 PARTITION p20160923 VALUES LESS THAN (736596) ENGINE = InnoDB,
 PARTITION p20160924 VALUES LESS THAN (736597) ENGINE = InnoDB,
 PARTITION p20160925 VALUES LESS THAN (736598) ENGINE = InnoDB,
 PARTITION p20160926 VALUES LESS THAN (736599) ENGINE = InnoDB,
 PARTITION p20160927 VALUES LESS THAN (736600) ENGINE = InnoDB,
 PARTITION p20160928 VALUES LESS THAN (736601) ENGINE = InnoDB,
 PARTITION p20160929 VALUES LESS THAN (736602) ENGINE = InnoDB,
 PARTITION p20160930 VALUES LESS THAN (736603) ENGINE = InnoDB,
 PARTITION p20161001 VALUES LESS THAN (736604) ENGINE = InnoDB,
 PARTITION p20161002 VALUES LESS THAN (736605) ENGINE = InnoDB,
 PARTITION p20161003 VALUES LESS THAN (736606) ENGINE = InnoDB,
 PARTITION p20161004 VALUES LESS THAN (736607) ENGINE = InnoDB,
 PARTITION p20161005 VALUES LESS THAN (736608) ENGINE = InnoDB,
 PARTITION p20161006 VALUES LESS THAN (736609) ENGINE = InnoDB,
 PARTITION p20161007 VALUES LESS THAN (736610) ENGINE = InnoDB,
 PARTITION p20161008 VALUES LESS THAN (736611) ENGINE = InnoDB,
 PARTITION p20161009 VALUES LESS THAN (736612) ENGINE = InnoDB,
 PARTITION p20161010 VALUES LESS THAN (736613) ENGINE = InnoDB,
 PARTITION p20161011 VALUES LESS THAN (736614) ENGINE = InnoDB,
 PARTITION p20161012 VALUES LESS THAN (736615) ENGINE = InnoDB,
 PARTITION p20161013 VALUES LESS THAN (736616) ENGINE = InnoDB,
 PARTITION p20161014 VALUES LESS THAN (736617) ENGINE = InnoDB,
 PARTITION p20161015 VALUES LESS THAN (736618) ENGINE = InnoDB,
 PARTITION p20161016 VALUES LESS THAN (736619) ENGINE = InnoDB,
 PARTITION p20161017 VALUES LESS THAN (736620) ENGINE = InnoDB,
 PARTITION p20161018 VALUES LESS THAN (736621) ENGINE = InnoDB,
 PARTITION p20161019 VALUES LESS THAN (736622) ENGINE = InnoDB,
 PARTITION p20161020 VALUES LESS THAN (736623) ENGINE = InnoDB,
 PARTITION p20161021 VALUES LESS THAN (736624) ENGINE = InnoDB,
 PARTITION p20161022 VALUES LESS THAN (736625) ENGINE = InnoDB,
 PARTITION p20161023 VALUES LESS THAN (736626) ENGINE = InnoDB,
 PARTITION p20161024 VALUES LESS THAN (736627) ENGINE = InnoDB,
 PARTITION p20161025 VALUES LESS THAN (736628) ENGINE = InnoDB,
 PARTITION p20161026 VALUES LESS THAN (736629) ENGINE = InnoDB,
 PARTITION p20161027 VALUES LESS THAN (736630) ENGINE = InnoDB,
 PARTITION p20161028 VALUES LESS THAN (736631) ENGINE = InnoDB,
 PARTITION p20161029 VALUES LESS THAN (736632) ENGINE = InnoDB,
 PARTITION p20161030 VALUES LESS THAN (736633) ENGINE = InnoDB,
 PARTITION p20161031 VALUES LESS THAN (736634) ENGINE = InnoDB,
 PARTITION p20161101 VALUES LESS THAN (736635) ENGINE = InnoDB,
 PARTITION p20161102 VALUES LESS THAN (736636) ENGINE = InnoDB,
 PARTITION p20161103 VALUES LESS THAN (736637) ENGINE = InnoDB,
 PARTITION p20161104 VALUES LESS THAN (736638) ENGINE = InnoDB,
 PARTITION p20161105 VALUES LESS THAN (736639) ENGINE = InnoDB,
 PARTITION p20161106 VALUES LESS THAN (736640) ENGINE = InnoDB,
 PARTITION p20161107 VALUES LESS THAN (736641) ENGINE = InnoDB,
 PARTITION p20161108 VALUES LESS THAN (736642) ENGINE = InnoDB,
 PARTITION p20161109 VALUES LESS THAN (736643) ENGINE = InnoDB,
 PARTITION p20161110 VALUES LESS THAN (736644) ENGINE = InnoDB,
 PARTITION p20161111 VALUES LESS THAN (736645) ENGINE = InnoDB,
 PARTITION p20161112 VALUES LESS THAN (736646) ENGINE = InnoDB,
 PARTITION p20161113 VALUES LESS THAN (736647) ENGINE = InnoDB,
 PARTITION p20161114 VALUES LESS THAN (736648) ENGINE = InnoDB,
 PARTITION p20161115 VALUES LESS THAN (736649) ENGINE = InnoDB,
 PARTITION p20161116 VALUES LESS THAN (736650) ENGINE = InnoDB,
 PARTITION p20161117 VALUES LESS THAN (736651) ENGINE = InnoDB,
 PARTITION p20161118 VALUES LESS THAN (736652) ENGINE = InnoDB,
 PARTITION p20161119 VALUES LESS THAN (736653) ENGINE = InnoDB,
 PARTITION p20161120 VALUES LESS THAN (736654) ENGINE = InnoDB,
 PARTITION p20161121 VALUES LESS THAN (736655) ENGINE = InnoDB,
 PARTITION p20161122 VALUES LESS THAN (736656) ENGINE = InnoDB,
 PARTITION p20161123 VALUES LESS THAN (736657) ENGINE = InnoDB,
 PARTITION p20161124 VALUES LESS THAN (736658) ENGINE = InnoDB,
 PARTITION p20161125 VALUES LESS THAN (736659) ENGINE = InnoDB,
 PARTITION p20161126 VALUES LESS THAN (736660) ENGINE = InnoDB,
 PARTITION p20161127 VALUES LESS THAN (736661) ENGINE = InnoDB,
 PARTITION p20161128 VALUES LESS THAN (736662) ENGINE = InnoDB,
 PARTITION p20161129 VALUES LESS THAN (736663) ENGINE = InnoDB,
 PARTITION p20161130 VALUES LESS THAN (736664) ENGINE = InnoDB,
 PARTITION p20161201 VALUES LESS THAN (736665) ENGINE = InnoDB,
 PARTITION p20161202 VALUES LESS THAN (736666) ENGINE = InnoDB,
 PARTITION p20161203 VALUES LESS THAN (736667) ENGINE = InnoDB,
 PARTITION p20161204 VALUES LESS THAN (736668) ENGINE = InnoDB,
 PARTITION p20161205 VALUES LESS THAN (736669) ENGINE = InnoDB,
 PARTITION p20161206 VALUES LESS THAN (736670) ENGINE = InnoDB,
 PARTITION p20161207 VALUES LESS THAN (736671) ENGINE = InnoDB,
 PARTITION p20161208 VALUES LESS THAN (736672) ENGINE = InnoDB,
 PARTITION p20161209 VALUES LESS THAN (736673) ENGINE = InnoDB,
 PARTITION p20161210 VALUES LESS THAN (736674) ENGINE = InnoDB,
 PARTITION p20161211 VALUES LESS THAN (736675) ENGINE = InnoDB,
 PARTITION p20161212 VALUES LESS THAN (736676) ENGINE = InnoDB,
 PARTITION p20161213 VALUES LESS THAN (736677) ENGINE = InnoDB,
 PARTITION p20161214 VALUES LESS THAN (736678) ENGINE = InnoDB,
 PARTITION p20161215 VALUES LESS THAN (736679) ENGINE = InnoDB,
 PARTITION p20161216 VALUES LESS THAN (736680) ENGINE = InnoDB,
 PARTITION p20161217 VALUES LESS THAN (736681) ENGINE = InnoDB,
 PARTITION p20161218 VALUES LESS THAN (736682) ENGINE = InnoDB,
 PARTITION p20161219 VALUES LESS THAN (736683) ENGINE = InnoDB,
 PARTITION p20161220 VALUES LESS THAN (736684) ENGINE = InnoDB,
 PARTITION p20161221 VALUES LESS THAN (736685) ENGINE = InnoDB,
 PARTITION p20161222 VALUES LESS THAN (736686) ENGINE = InnoDB,
 PARTITION p20161223 VALUES LESS THAN (736687) ENGINE = InnoDB,
 PARTITION p20161224 VALUES LESS THAN (736688) ENGINE = InnoDB,
 PARTITION p20161225 VALUES LESS THAN (736689) ENGINE = InnoDB,
 PARTITION p20161226 VALUES LESS THAN (736690) ENGINE = InnoDB,
 PARTITION p20161227 VALUES LESS THAN (736691) ENGINE = InnoDB,
 PARTITION p20161228 VALUES LESS THAN (736692) ENGINE = InnoDB,
 PARTITION p20161229 VALUES LESS THAN (736693) ENGINE = InnoDB,
 PARTITION p20161230 VALUES LESS THAN (736694) ENGINE = InnoDB,
 PARTITION p20161231 VALUES LESS THAN (736695) ENGINE = InnoDB,
 PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
 
 
 
 mysql> select count(*) from ClientActionTrack partition (p20160809);
+----------+
| count(*) |
+----------+
|    68462 |
+----------+
1 row in set (0.02 sec)

mysql> explain select * from  ClientActionTrack partition (p20160809);
+----+-------------+-------------------+------+---------------+------+---------+------+-------+-------+
| id | select_type | table             | type | possible_keys | key  | key_len | ref  | rows  | Extra |
+----+-------------+-------------------+------+---------------+------+---------+------+-------+-------+
|  1 | SIMPLE      | ClientActionTrack | ALL  | NULL          | NULL | NULL    | NULL | 66570 | NULL  |
+----+-------------+-------------------+------+---------------+------+---------+------+-------+-------+
1 row in set (0.00 sec)



mysql>  select count(*) from ClientActionTrack where startTime>='2016-08-09 00:00:00' and startTime<='2016-08-09 23:59:59';
+----------+
| count(*) |
+----------+
|    68462 |
+----------+
1 row in set (0.04 sec)

mysql> select count(*) from ClientActionTrack partition(p20160809);
+----------+
| count(*) |
+----------+
|    68462 |
+----------+
1 row in set (0.02 sec)


) ENGINE=InnoDB AUTO_INCREMENT=10251622 DEFAULT CHARSET=utf8 COMMENT='用户访问记录表'
/*!50100 PARTITION BY RANGE (TO_DAYS(startTime))
(PARTITION p20151124 VALUES LESS THAN (736292) ENGINE = InnoDB,
 
 PARTITION p20151125 VALUES LESS THAN (736293) ENGINE = InnoDB,
 
 mysql> select TO_DAYS('2015-11-25 23:59:59') from  Client limit 1; 
+--------------------------------+
| TO_DAYS('2015-11-25 23:59:59') |
+--------------------------------+
|                         736292 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select TO_DAYS('2015-11-26 00:00:00') from  Client limit 1;
+--------------------------------+
| TO_DAYS('2015-11-26 00:00:00') |
+--------------------------------+
|                         736293 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> SELECT FROM_DAYS(736293);
+-------------------+
| FROM_DAYS(736293) |
+-------------------+
| 2015-11-26        |
+-------------------+
1 row in set (0.00 sec)


mysql> SELECT FROM_DAYS(736294);
+-------------------+
| FROM_DAYS(736294) |
+-------------------+
| 2015-11-27        |
+-------------------+
1 row in set (0.00 sec)