Mysql – Track row origin in MySQL multi source replication

MySQLreplication

Hi I would like to create a multi source replication topology where a few different master databases replicate to one big slave database.
I want to know for each and every row on the slave from which master it came from.
My first instinct would be to add a "system_id" column on each master table but I wonder if there is a better way to track the origin of the rows.

Thanks

Best Answer

Are the rows going into the same table(s)? If so, your suggestion of an extra column from the Master is probably the only way.

Or are the rows going into different databases (or tables)? If so, then nothing is needed -- the different dbs/tables provide the clue.

Another approach may be "replicate rewrite" -- this turns same table into different table. If you then need to "combine" the data (on the unified Slave), use UNION ALL and/or a VIEW. See here.