Note – this post is a footnote for my MySQL users conference presentation Sharding Using Spockproxy: A Sharding-only Version of MySQL Proxy.
When you finished my last blog post you have a directory for each shard full of load files. The tables had been created so now we’re ready to load these files.
These two queries will generate load scripts, modify them as needed or write your own.
SELECT concat(‘ LOAD DATA INFILE \’
/db0′, ‘/’, st.table_name, ‘\’ INTO TABLE ‘, st.table_name, ‘;’)
AS ”
FROM shard_table_directory st
WHERE status = ‘universal’;
and run this once for each shard (change the sr.database_id = 1 to each database_id).
SELECT concat(‘ LOAD DATA INFILE \’
/db’, database_id, ‘/’, st.table_name, sr.range_id, ‘\’ INTO
TABLE ‘, …