Partycjonowanie

CREATE TABLE `salaries_2` (
  `emp_no` int(11) NOT NULL,
  `salary` int(11) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL
) 

PARTITION BY RANGE(YEAR(from_date)) (
    PARTITION p0 VALUES LESS THAN (1985),
    PARTITION p1 VALUES LESS THAN (1995),
    PARTITION p2 VALUES LESS THAN (2000),
    PARTITION p3 VALUES LESS THAN (2002),
    PARTITION p4 VALUES LESS THAN MAXVALUE
)

explain select count(*) from salaries_2 where from_date = '2001-01-01';

CREATE TABLE `salaries_3` (
  `emp_no` int(11) NOT NULL,
  `salary` int(11) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL
) 

PARTITION BY HASH(emp_no)
PARTITIONS 6;
Komentarze wyłączone