INSERT INTO last_visits ( id, domain ) SELECT DISTINCT id, domain FROM heap_in