php - Fastest way to find different rows in two mysql tables -


i have 2 identical tables. second 1 "slave" of first one. first table has autoincrement int id column , second has id2 indexed unique int, not autoincremented. id2 analog of id.

i need find fastest way detect new rows in second table (those id2 not exist in first table) , vise versa, new rows in first table (those id not exist in second table). fastest way found

select sql_no_cache     tab1.id `tab1` left join `tab2`      on tab1.id = tab2.id2     isnull(tab2.id2) 

takes out 2.5 seconds on ~200k records. may propose faster result?

select * tab2      not exists (select 'x' tab1          tab1.id= tab2.id) 

i think query give little faster result.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -