select - Optimize MySQL query with larger database -


how can write below query efficiently

select distinct a.id  table1 a.id not in (select distinct b.id                                   table2 b) 

post query result inserted table2 via insert query.

the problem table1 has approx ~75300 records , table2 has ~74000 records.

this query executed every 10 mins , takes approx 1.5 mins execute.

any possibilities query faster?

try using join

select distinct a.id table1 left join table2 b on a.id = b.id b.id null 

the left join clause select rows a regardless of whether or not there matching rows in b. can use where clause @ end ensure rows returned a have no match in b


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -