Changes between Version 9 and Version 10 of Partition


Ignore:
Timestamp:
06/16/22 07:33:59 (2 years ago)
Author:
krit
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Partition

    v9 v10  
    7474}}}
    7575
     76== Test Script ==
     77
     78Following is test script to parse to mysql command
     79{{{
     80CREATE DATABASE Payment;
     81USE Payment;
     82CREATE TABLE payments (
     83     customerNumber int(11) NOT NULL,
     84     checkNumber varchar(50) NOT NULL,
     85     paymentDate datetime NOT NULL,
     86     amount decimal(10,2) NOT NULL  )
     87     ENGINE=InnoDB PARTITION BY RANGE( TO_DAYS(paymentDate) )
     88                 ( PARTITION p2003 VALUES LESS THAN (TO_DAYS('2004-01-01')),
     89                   PARTITION p2004 VALUES LESS THAN (TO_DAYS('2005-01-01')),
     90                   PARTITION p2005 VALUES LESS THAN (TO_DAYS('2006-01-01')),
     91                   PARTITION p3 VALUES LESS THAN MAXVALUE );
     92
     93SHOW CREATE TABLE payments \G
     94INSERT INTO payments select * from classicmodels.payments;
     95
     96EXPLAIN SELECT * FROM payments where paymentDate = "2005-05-03";
     97EXPLAIN SELECT * FROM classicmodels.payments where paymentDate = "2005-05-03";
     98CREATE TABLE payments_2004 like payments;
     99SHOW CREATE TABLE payments_2004 \G
     100ALTER TABLE payments_2004 REMOVE PARTITIONING;
     101SHOW CREATE TABLE payments_2004 \G
     102ALTER TABLE payments EXCHANGE PARTITION p2004 WITH TABLE payments_2004;
     103SELECT COUNT(*)  FROM  payments;
     104SELECT COUNT(*)  FROM  payments_2004;
     105
     106ALTER TABLE payments EXCHANGE PARTITION p2004 WITH TABLE payments_2004;
     107SELECT COUNT(*)  FROM  payments;
     108SELECT COUNT(*)  FROM  payments_2004;
     109
     110-------------- query with parition ------------
     111SELECT * FROM table1 PARTITION (A, B) WHERE col1< 10
     112
     113SELECT * FROM payments PARTITION (p2005) where paymentDate = "2005-05-03";
     114EXPLAIN SELECT * FROM payments PARTITION (p2005) WHERE paymentDate = "2005-05-03";
     115EXPLAIN SELECT * FROM payments WHERE customerNumber = 209;
     116EXPLAIN SELECT * FROM payments PARTITION (p2005) WHERE customerNumber = 209;
     117
     118------------ with primary key -----------------
     119EXPLAIN SELECT * FROM classicmodels.payments WHERE customerNumber = 209;
     120EXPLAIN SELECT * FROM classicmodels.payments WHERE amount = 4632.31;
     121EXPLAIN SELECT * FROM payments WHERE amount = 4632.31;
     122EXPLAIN SELECT * FROM payments PARTITION (p2004)  WHERE amount = 4632.31;
     123
     124
     125}}}