以下技术应用于最优质的水果的鲜果篮
Mysql Cluster does sharding (evenly distributes the data between data nodes) + replication ( every fragment of data stored twice).
So simple table like,
|test|CREATETABLE`test`(`id`bigint(20)NOTNULLAUTO_INCREMENT,`v1`char(255)DEFAULTNULL,PRIMARYKEY(`id`))ENGINE=ndbcluster AUTO_INCREMENT=1871780DEFAULTCHARSET=latin1
If you check the information_schema, you will see partitions for this table
mysql>selectpartition_name,table_rowsfrominformation_schema.PARTITIONSwheretable_name='test'andtable_schema='test1';+----------------+------------+|partition_name|table_rows|+----------------+------------+|p0|518667||p1|518900||p2|517385||p3|519050|+----------------+------------+4rowsinset(0.02sec)
Partition p0,p2 stands for data node 1, and p1,p3 for node 2. The data is distributed based on the PRIMARY KEY (or and artificial key, if now primary key defined).
Select chooses the node to read from based on this partitioning, so if you use explain
mysql>explain partitionsselectid,v1fromtestwhereid=1\G***************************1.row***************************id:1select_type:SIMPLEtable:test
partitions:p3
type:eq_ref
possible_keys:PRIMARYkey:PRIMARYkey_len:8ref:constrows:1Extra:NULL1rowinset(0.00sec)mysql>explain partitionsselectid,v1fromtestwhereid=2\G***************************1.row***************************id:1select_type:SIMPLEtable:test
partitions:p2
type:eq_ref
possible_keys:PRIMARYkey:PRIMARYkey_len:8ref:constrows:1Extra:NULL
The record for id=92 will be read from only one of the data nodes (may the geographical distributed one), but unfortunately it is not just for id 92.
The best is to create a separate table for customer id 92 (on a separate node), and rewrite your application to read from that table/node. To have a solution transparent to the app, you might useMysql
Proxy