I have two tables, I need all rows from the first that don’t appear in the second.
The tables can be destroyed as they’re dumps from other tables.
First table has ~57million rows. Second table has ~10million rows.
Both of these queries are taking forever for obvious reasons, please help me do this quicker.
SELECT * FROM db.first WHERE id NOT IN (SELECT id FROM db.second)
DELETE FROM db.first WHERE id IN (SELECT id FROM db.second)
Edit: I don’t need any records from the second table, I only need rows that appear in the first table that don’t appear in the second table.
It would probably be a lot quicker using joins:
and the delete: