![]() | |
#1
| |||
| |||
|
|
PARTITION_NAME | TABLE_ROWS | +----------------+------------+ p0 | 18 | p1 | 4671 | p2 | 118171 | p3 | 30875 | p4 | 28924 | p5 | 10334 | p6 | 25045 | p7 | 12661 | p8 | 28544 | p9 | 185148 | p10 | 70322 | p11 | 0 | p12 | 0 | p13 | 0 | p14 | 0 | p15 | 0 | p16 | 0 | p17 | 0 | p18 | 0 | p19 | 0 | p20 | 0 | +----------------+------------+ |
#2
| |||
| |||
|
|
Hi guys, I just upgraded our database to 5.5 so I could start using partitions. I created a test table to make sure partitions were working and sure enough they was. So I then created the main table as follows: mysql>SHOW CREATE TABLE `logger`\G *************************** 1. row *************************** * * * *Table: logger Create Table: CREATE TABLE `logger` ( * `id` int(15) unsigned NOT NULL AUTO_INCREMENT, * `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', * `account_no` char(11) NOT NULL, * `database_area` char(100) NOT NULL, * `col_name` varchar(255) DEFAULT NULL, * `before` varchar(255) DEFAULT NULL, * `after` varchar(255) DEFAULT NULL, * `uid` int(11) NOT NULL, * PRIMARY KEY (`id`,`date`), * KEY `account_no` (`account_no`), * KEY `col_name` (`col_name`), * KEY `database_area` (`database_area`), * KEY `after` (`after`), * KEY `before` (`before`) ) ENGINE=MyISAM AUTO_INCREMENT=514714 DEFAULT CHARSET=utf8 /*!50500 PARTITION BY RANGE *COLUMNS(`date`) (PARTITION p0 VALUES LESS THAN ('2009-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p1 VALUES LESS THAN ('2009-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p2 VALUES LESS THAN ('2009-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p3 VALUES LESS THAN ('2009-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p4 VALUES LESS THAN ('2010-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p5 VALUES LESS THAN ('2010-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p6 VALUES LESS THAN ('2010-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p7 VALUES LESS THAN ('2010-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p8 VALUES LESS THAN ('2011-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p9 VALUES LESS THAN ('2011-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p10 VALUES LESS THAN ('2011-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p11 VALUES LESS THAN ('2011-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p12 VALUES LESS THAN ('2012-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p13 VALUES LESS THAN ('2012-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p14 VALUES LESS THAN ('2012-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p15 VALUES LESS THAN ('2012-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p16 VALUES LESS THAN ('2013-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p17 VALUES LESS THAN ('2013-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p18 VALUES LESS THAN ('2013-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p19 VALUES LESS THAN ('2013-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p20 VALUES LESS THAN (MAXVALUE) ENGINE = MyISAM) */ 1 row in set (0.01 sec) I imported all our existing data into the table and tested it: mysql> SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'logger'; +----------------+------------+ | PARTITION_NAME | TABLE_ROWS | +----------------+------------+ | p0 * * * * * * | * * * * 18 | | p1 * * * * * * | * * * 4671 | | p2 * * * * * * | * * 118171 | | p3 * * * * * * | * * *30875 | | p4 * * * * * * | * * *28924 | | p5 * * * * * * | * * *10334 | | p6 * * * * * * | * * *25045 | | p7 * * * * * * | * * *12661 | | p8 * * * * * * | * * *28544 | | p9 * * * * * * | * * 185148 | | p10 * * * * * *| * * *70322 | | p11 * * * * * *| * * * * *0 | | p12 * * * * * *| * * * * *0 | | p13 * * * * * *| * * * * *0 | | p14 * * * * * *| * * * * *0 | | p15 * * * * * *| * * * * *0 | | p16 * * * * * *| * * * * *0 | | p17 * * * * * *| * * * * *0 | | p18 * * * * * *| * * * * *0 | | p19 * * * * * *| * * * * *0 | | p20 * * * * * *| * * * * *0 | +----------------+------------+ 21 rows in set (0.00 sec) However when i run queries against it, it doesnt seem to select the partitions correctly: mysql> EXPLAIN PARTITIONS SELECT `id` FROM `logger` WHERE `date` BETWEEN '2009-07-01 00:00:00' and '2009-10-01 00:00:00'\G *************************** 1. row *************************** * * * * * *id: 1 * select_type: SIMPLE * * * * table: logger * *partitions: p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14, p15,p16,p17,p18,p19,p20 * * * * *type: index possible_keys: NULL * * * * * key: PRIMARY * * * key_len: 12 * * * * * ref: NULL * * * * *rows: 514713 * * * * Extra: Using where; Using index 1 row in set (0.00 sec) As you can see it is showing all partitions instead of p2 and p3. I would be grateful if anyone could shed some light into what I am doing wrong. Regards Dave. |
#3
| |||
| |||
|
|
On Apr 18, 4:58*am, David <david.greenh... (AT) gmail (DOT) com> wrote: Hi guys, I just upgraded our database to 5.5 so I could start using partitions. I created a test table to make sure partitions were working and sure enough they was. So I then created the main table as follows: mysql>SHOW CREATE TABLE `logger`\G *************************** 1. row *************************** * * * *Table: logger Create Table: CREATE TABLE `logger` ( * `id` int(15) unsigned NOT NULL AUTO_INCREMENT, * `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', * `account_no` char(11) NOT NULL, * `database_area` char(100) NOT NULL, * `col_name` varchar(255) DEFAULT NULL, * `before` varchar(255) DEFAULT NULL, * `after` varchar(255) DEFAULT NULL, * `uid` int(11) NOT NULL, * PRIMARY KEY (`id`,`date`), * KEY `account_no` (`account_no`), * KEY `col_name` (`col_name`), * KEY `database_area` (`database_area`), * KEY `after` (`after`), * KEY `before` (`before`) ) ENGINE=MyISAM AUTO_INCREMENT=514714 DEFAULT CHARSET=utf8 /*!50500 PARTITION BY RANGE *COLUMNS(`date`) (PARTITION p0 VALUES LESS THAN ('2009-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p1 VALUES LESS THAN ('2009-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p2 VALUES LESS THAN ('2009-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p3 VALUES LESS THAN ('2009-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p4 VALUES LESS THAN ('2010-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p5 VALUES LESS THAN ('2010-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p6 VALUES LESS THAN ('2010-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p7 VALUES LESS THAN ('2010-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p8 VALUES LESS THAN ('2011-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p9 VALUES LESS THAN ('2011-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p10 VALUES LESS THAN ('2011-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p11 VALUES LESS THAN ('2011-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p12 VALUES LESS THAN ('2012-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p13 VALUES LESS THAN ('2012-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p14 VALUES LESS THAN ('2012-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p15 VALUES LESS THAN ('2012-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p16 VALUES LESS THAN ('2013-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p17 VALUES LESS THAN ('2013-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p18 VALUES LESS THAN ('2013-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p19 VALUES LESS THAN ('2013-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p20 VALUES LESS THAN (MAXVALUE) ENGINE = MyISAM) */ 1 row in set (0.01 sec) I imported all our existing data into the table and tested it: mysql> SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'logger'; +----------------+------------+ | PARTITION_NAME | TABLE_ROWS | +----------------+------------+ | p0 * * * * * * | * * * * 18 | | p1 * * * * * * | * * * 4671 | | p2 * * * * * * | * * 118171 | | p3 * * * * * * | * * *30875 | | p4 * * * * * * | * * *28924 | | p5 * * * * * * | * * *10334 | | p6 * * * * * * | * * *25045 | | p7 * * * * * * | * * *12661 | | p8 * * * * * * | * * *28544 | | p9 * * * * * * | * * 185148 | | p10 * * * * * *| * * *70322 | | p11 * * * * * *| * * * * *0 | | p12 * * * * * *| * * * * *0 | | p13 * * * * * *| * * * * *0 | | p14 * * * * * *| * * * * *0 | | p15 * * * * * *| * * * * *0 | | p16 * * * * * *| * * * * *0 | | p17 * * * * * *| * * * * *0 | | p18 * * * * * *| * * * * *0 | | p19 * * * * * *| * * * * *0 | | p20 * * * * * *| * * * * *0 | +----------------+------------+ 21 rows in set (0.00 sec) However when i run queries against it, it doesnt seem to select the partitions correctly: mysql> EXPLAIN PARTITIONS SELECT `id` FROM `logger` WHERE `date` BETWEEN '2009-07-01 00:00:00' and '2009-10-01 00:00:00'\G *************************** 1. row *************************** * * * * * *id: 1 * select_type: SIMPLE * * * * table: logger * *partitions: p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14, p15,p16,p17,p18,p19,p20 * * * * *type: index possible_keys: NULL * * * * * key: PRIMARY * * * key_len: 12 * * * * * ref: NULL * * * * *rows: 514713 * * * * Extra: Using where; Using index 1 row in set (0.00 sec) As you can see it is showing all partitions instead of p2 and p3. I would be grateful if anyone could shed some light into what I am doing wrong. |
#4
| |||
| |||
|
|
In article <d5adc5cb-77a1-4621-9b89-723beb7b2... (AT) hd10g2000vbb (DOT) googlegroups.com>, onedbguru *<onedbg... (AT) yahoo (DOT) com> wrote: On Apr 18, 4:58*am, David <david.greenh... (AT) gmail (DOT) com> wrote: Hi guys, I just upgraded our database to 5.5 so I could start using partitions. I created a test table to make sure partitions were working and sure enough they was. So I then created the main table as follows: mysql>SHOW CREATE TABLE `logger`\G *************************** 1. row *************************** * * * *Table: logger Create Table: CREATE TABLE `logger` ( * `id` int(15) unsigned NOT NULL AUTO_INCREMENT, * `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', * `account_no` char(11) NOT NULL, * `database_area` char(100) NOT NULL, * `col_name` varchar(255) DEFAULT NULL, * `before` varchar(255) DEFAULT NULL, * `after` varchar(255) DEFAULT NULL, * `uid` int(11) NOT NULL, * PRIMARY KEY (`id`,`date`), * KEY `account_no` (`account_no`), * KEY `col_name` (`col_name`), * KEY `database_area` (`database_area`), * KEY `after` (`after`), * KEY `before` (`before`) ) ENGINE=MyISAM AUTO_INCREMENT=514714 DEFAULT CHARSET=utf8 /*!50500 PARTITION BY RANGE *COLUMNS(`date`) (PARTITION p0 VALUES LESS THAN ('2009-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p1 VALUES LESS THAN ('2009-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p2 VALUES LESS THAN ('2009-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p3 VALUES LESS THAN ('2009-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p4 VALUES LESS THAN ('2010-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p5 VALUES LESS THAN ('2010-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p6 VALUES LESS THAN ('2010-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p7 VALUES LESS THAN ('2010-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p8 VALUES LESS THAN ('2011-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p9 VALUES LESS THAN ('2011-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p10 VALUES LESS THAN ('2011-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p11 VALUES LESS THAN ('2011-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p12 VALUES LESS THAN ('2012-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p13 VALUES LESS THAN ('2012-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p14 VALUES LESS THAN ('2012-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p15 VALUES LESS THAN ('2012-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p16 VALUES LESS THAN ('2013-01-01 00:00:00') ENGINE = MyISAM, *PARTITION p17 VALUES LESS THAN ('2013-04-01 00:00:00') ENGINE = MyISAM, *PARTITION p18 VALUES LESS THAN ('2013-07-01 00:00:00') ENGINE = MyISAM, *PARTITION p19 VALUES LESS THAN ('2013-10-01 00:00:00') ENGINE = MyISAM, *PARTITION p20 VALUES LESS THAN (MAXVALUE) ENGINE = MyISAM) */ 1 row in set (0.01 sec) I imported all our existing data into the table and tested it: mysql> SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'logger'; +----------------+------------+ | PARTITION_NAME | TABLE_ROWS | +----------------+------------+ | p0 * * * * * * | * * * * 18 | | p1 * * * * * * | * * * 4671 | | p2 * * * * * * | * * 118171 | | p3 * * * * * * | * * *30875 | | p4 * * * * * * | * * *28924 | | p5 * * * * * * | * * *10334 | | p6 * * * * * * | * * *25045 | | p7 * * * * * * | * * *12661 | | p8 * * * * * * | * * *28544 | | p9 * * * * * * | * * 185148 | | p10 * * * * * *| * * *70322 | | p11 * * * * * *| * * * * *0 | | p12 * * * * * *| * * * * *0 | | p13 * * * * * *| * * * * *0 | | p14 * * * * * *| * * * * *0 | | p15 * * * * * *| * * * * *0 | | p16 * * * * * *| * * * * *0 | | p17 * * * * * *| * * * * *0 | | p18 * * * * * *| * * * * *0 | | p19 * * * * * *| * * * * *0 | | p20 * * * * * *| * * * * *0 | +----------------+------------+ 21 rows in set (0.00 sec) However when i run queries against it, it doesnt seem to select the partitions correctly: mysql> EXPLAIN PARTITIONS SELECT `id` FROM `logger` WHERE `date` BETWEEN '2009-07-01 00:00:00' and '2009-10-01 00:00:00'\G *************************** 1. row *************************** * * * * * *id: 1 * select_type: SIMPLE * * * * table: logger * *partitions: p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14, p15,p16,p17,p18,p19,p20 * * * * *type: index possible_keys: NULL * * * * * key: PRIMARY * * * key_len: 12 * * * * * ref: NULL * * * * *rows: 514713 * * * * Extra: Using where; Using index 1 row in set (0.00 sec) As you can see it is showing all partitions instead of p2 and p3. I would be grateful if anyone could shed some light into what I am doing wrong. Try adding: KEY `date` (`date`), At the moment, it doesn't have any index beginning with `date`. That is why the explain says "possible_keys: NULL" and can't choose the specific partitions. Cheers Tony -- Tony Mountifield Work: t... (AT) softins (DOT) co.uk -http://www.softins.co.uk Play: t... (AT) mountifield (DOT) org -http://tony.mountifield.org |
#5
| |||
| |||
|
|
On Apr 19, 12:34*pm, t... (AT) mountifield (DOT) org (Tony Mountifield) wrote: I would be grateful if anyone could shed some light into what I am doing wrong. Try adding: KEY `date` (`date`), At the moment, it doesn't have any index beginning with `date`. That is why the explain says "possible_keys: NULL" and can't choose the specific partitions. Very strange, I removed the my.cnf file and restarted mysql and it worked fine. Put the conf file back - restarted and its back to how it was above. So something in the my.cnf is doing this!! will have to go through every line to find out the culprit. |
![]() |
| Thread Tools | |
| Display Modes | |
| |