MySQL Forums
Forum List  »  NDB clusters

Re: NDBCluster partitioning by non unique column
Posted by: Aftab Khan
Date: July 18, 2014 08:03AM

yes you can partition by composite primary key. Please note, if you define an explicit partitioning scheme for an NDB table, the table must have an explicit primary key, and any columns used in the partitioning expression must be part of this key.

for example:

mysql> show create table orders\G
*************************** 1. row ***************************
       Table: orders
Create Table: CREATE TABLE `orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_id` int(11) NOT NULL,
  PRIMARY KEY (`id`,`customer_id`) # COMPOSITE PRIMARY KEY
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (customer_id) */ # PARTITION KEY IS CUSTOMER_ID
1 row in set (0.08 sec)


You could also use composite primary key as a new partitioning key:

mysql> alter table orders partition by key (id,customer_id);
Query OK, 0 rows affected (3.20 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show create table orders\G
*************************** 1. row ***************************
       Table: orders
Create Table: CREATE TABLE `orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_id` int(11) NOT NULL,
  PRIMARY KEY (`id`,`customer_id`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (id,customer_id) */ # PARTITION BY COMPOSITE KEY 
1 row in set (0.07 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: NDBCluster partitioning by non unique column
691
July 18, 2014 08:03AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.