As mentioned in a blog 2 years ago I worked on a new
partitioning feature:
I've been busy with many other things but now I've taken this
work a step forward and will most likely set-up a preview tree
of this feature in a short time.
The new feature adds the possibility to perform partitioning
on any type of column also for range and list partitioning
(has been possible for KEY partitioning all the time). It also
adds a new function to the MySQL Server and this function is
also a monotonic function which means it gets a nice treatment
of the partition pruning. This new function is TO_SECONDS which
works very similarly to TO_DAYS.
So here are couple of new cases of what one will be able to do:
create table t1 (d date)
partition by range column_list(d)
( partition p0 values less than (column_list('1999-01-01')),
partition p1 values less than (column_list('2000-01-01')));
create table t1 (a date)
partition by range(to_seconds(a))
(partition p0 values less than (to_seconds('2004-01-01')),
partition p1 values less than (to_seconds('2005-01-01')));
select * from t1 where a <= '2003-12-31';
This select will be discovered to only find values in p0 by
the partition pruning optimisation step.
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p2 values less than (column_list(99,99)),
partition p1 values less than (column_list(99,999)));
insert into t1 values (99,998);
select * from t1 where a = 99 and b = 998;
This select statement will discover that it can only
be any records in the p1 partition and avoid
scanning the p0 partition. Thus partitioning works
in very much the same manner as a first step index.
I'm excited about the opportunity to partition on any type of column. Currently we've re-factored some of our columns to be ints just so that we could partition on them.
ReplyDeleteI'll be looking forward to downloading the source when it's ready :)