I need to get all records from table1 minus all (matching) records in table2. Green zone in the image.
The matching has to be done by pairs (values from 2 columns) Here is the query that I'm doing:
SELECT col1, col2
FROM table1
WHERE (col1, col2) NOT IN
(SELECT col1, col2
FROM table2)
tabel1 has 317789 records and table2 has 289639 records. I got index(col1), index(col2) and index(col1, col2) on both tables.
Query is runnig for over than 30min now... Help!! :)


IN/NOT INwith multiple values can't use indexes in MySQL. You should avoid it.