I have two almost identical tables. Second one is a "slave" of first one. First table has autoincrement int ID column and second also has ID2 which is indexed unique int, but not autoincremented. ID2 is an analog of ID.
I need to find fastest way to detect new rows in second table (those ID2 which not exist in first table) and vise versa, new rows in first table (those ID which not exist in second table). A fastest way I found is
select SQL_NO_CACHE tab1.ID from `tab1` left join `tab2` on tab1.ID = tab2.ID2 where isnull(tab2.ID2)
Takes out 2.5 seconds on ~200k records. What you may propose to get faster result?