6/25/2009

[MySQL][VP]Vertical Partitioning storage engine 0.1 released

I'm pleased to announce a release of a new storage engine "Vertical Partitioning storage engine".
http://launchpad.net/vpformysql
You can use relation tables of one to one like one table by using Vertical Partitioning storage engine.
It is near by a view of joined relation tables of one to one but different point is following.
- It can insert.
- It can do partition pruning.(Not use partitions that are no necessity)


Vertical Partitioning storage engine can use following purposes.
(Vertical Partitioning table is called "parent table", integrated tables are called "child table")


1.A MySQL's InnoDB table that has the big record size is very slow if a select statement needs table scanning with a lot of records.
  Vertical Partitioning is good for resolving this performance problem.

  For example, you can solve a performance issue for "select col_d from tbl_a" by using following partitions.
  Before partitioning
    create table tbl_a(
      col_a int primary key,
      col_b int,
      col_c int,
      col_d int,
      col_e varchar(255),
      col_f varchar(255),
      col_g varchar(255),
      col_h varchar(255),
      col_i varchar(255),
      col_j text,
      key idx_a(col_b, col_c),
      key idx_b(col_c, col_j(100))
    )engine=InnoDB;

  After partitioning
    create table tbl_b(
      col_a int primary key,
      col_b int,
      col_c int,
      col_d int,
      key idx_a(col_b, col_c)
    )engine=InnoDB;
    create table tbl_c(
      col_a int primary key,
      col_c int,
      col_e varchar(255),
      col_f varchar(255),
      col_g varchar(255),
      col_h varchar(255),
      col_i varchar(255),
      col_j text,
      key idx_b(col_c, col_j(100))
    )engine=InnoDB;
    create table tbl_a(
      col_a int primary key,
      col_b int,
      col_c int,
      col_d int,
      col_e varchar(255),
      col_f varchar(255),
      col_g varchar(255),
      col_h varchar(255),
      col_i varchar(255),
      col_j text,
      key idx_a(col_b, col_c),
      key idx_b(col_c, col_j(100))
    )engine=VP
    comment 'table_name_list "tbl_b tbl_c"';
  Note: Vertical Partitioning storage engine can use same column in different child tables. You can use flexible partition design by this feature but you should note that a lot of same columns causes updating performance issues.


2.MySQL Cluster (ndb) is not good for using text columns.
  Vertical Partitioning can use different storage engines for one table.
  As a result, MySQL Cluster can use only for strong point columns.
  Example of mixed storage engines.
    create table tbl_b(
      col_a int primary key,
      col_b int,
      col_c int,
      key idx_a(col_b, col_c)
    )engine=ndb ......;
    create table tbl_c(
      col_a int primary key,
      col_c int,
      col_d varchar(255),
      col_e text,
      key idx_b(col_c, col_e(100))
    )engine=Spider ......;
    create table tbl_a(
      col_a int primary key,
      col_b int,
      col_c int,
      col_d varchar(255),
      col_e text,
      key idx_a(col_b, col_c),
      key idx_b(col_c, col_e(100))
    )engine=VP
    comment 'table_name_list "tbl_b tbl_c"';


3.MySQL does not support multi shaped partitioning.
  Vertical Partitioning storage engine supports multi shaped partitioning.
  Multi shaped partitioning is dividing a table by multiple partitioning rules.
  You can use tables that dividing into detail information table and index tables like one table by this feature. And you can shard each table by using Spider storage engine.

  Before partitioning
    create table employees (
      id int primary key,
      fname varchar(30),
      lname varchar(30),
      hired date not null default '1970-01-01',
      separated date not null default '9999-12-31',
      job_code int,
      store_id int
    )engine=InnoDB;

  After partitioning
    create table emp_pk (
      id int not null,
      separated date not null default '9999-12-31',
      unique idx_a(id),
      key idx_b(id, separated)
    )engine=InnoDB
    partition by hash(id)
    partitions 4;
    create table emp_detail (
      id int not null,
      fname varchar(30),
      lname varchar(30),
      hired date not null default '1970-01-01',
      separated date not null default '9999-12-31',
      job_code int,
      store_id int,
      key idx_a(id, separated)
    )engine=InnoDB
    partition by range ( year(separated) ) (
      partition p0 values less than (1991),
      partition p1 values less than (1996),
      partition p2 values less than (2001),
      partition p3 values less than maxvalue
    );
    create table employees (
      id int not null,
      fname varchar(30),
      lname varchar(30),
      hired date not null default '1970-01-01',
      separated date not null default '9999-12-31',
      job_code int,
      store_id int,
      primary key(id, separated)
    )engine=VP
    comment 'table_name_list "emp_pk emp_detail", pk_correspond_mode "1"';

  Note: In this case, parent table's primary key has columns that using both child table partitioning rules for using partition pruning.
  (In the future, I will improve this to become "parent table's primary key has only real primary key (id) and child tables can use partition pruning")


4.Vertical Partitioning can add "parallel columns searching" to other storage engines with supporting "parallel searching" like spider storage engine.(Now developping)


5.Vertical Partitioning storage engine can use for partitioning wrapper because Vertical Partitioning storage engine supports MySQL's table partitioning.
  You can use each partition like tables by this feature.(Don't use this feature because now developping)

  Example
    create table tbl_b(
      col_a int not null,
      col_b varchar(20),
      col_c int not null,
      primary key(col_a)
    )engine=InnoDB;
    create table tbl_c(
      col_a int not null,
      col_b varchar(20),
      col_c int not null,
      primary key(col_a)
    )engine=InnoDB;
    create table tbl_d(
      col_a int not null,
      col_b varchar(20),
      col_c int not null,
      primary key(col_a)
    )engine=InnoDB;
    create table tbl_a(
      col_a int not null,
      col_b varchar(20),
      col_c int not null,
      primary key(col_a)
    )engine=VP
    partition by hash(col_a)
    (
      partition pt1 comment='table_name_list "tbl_b"',
      partition pt2 comment='table_name_list "tbl_c"',
      partition pt3 comment='table_name_list "tbl_d"'
    );


In this time, Vertical Partitioning storage engine is alpha version and some features can not use yet but I will develop fast for adding features.
Enjoy!

1 comment:

  1. That is awesome. I've been waiting to see someone create an engine like this!
    -Brian

    ReplyDelete