BUT... Create the sub-tables exactly as you would for a MERGE table. Note the indexes.
create table chunk1 (num int, data varchar(255), key (num)); create table chunk2 (num int, data varchar(255), key (num));
Create a VIEW that is simply a UNION of the data sets of the sub-tables.
create view chunk as select * from chunk1 union select * from chunk2;
Create another VIEW that aggregates the sizes of the sub-tables.
create view counts as select count(*) as records, 1 as chunk from chunk1 union select count(*) as records, 2 as chunk from chunk2;
Now a cool thing - use the counts VIEW to implement round robin INSERT operations for automatic load balancing between chunk tables. Extra cool if the FEDERATED engine is used for the sub-tables:
<?php function next_chunk() { $rs = …[Read more]