Delete query does not end
Plan A:


Create temp table with num and max(id).  400K rows
Chunk that table to do only 1000 deletes at a time; there would be a JOIN in the DELETE to the temp table.


More on Chunking for DELETE.

Plan B:

You need to keep 60% of the table, correct?  So, it may be faster to rebuild the table with only the desired rows.

CREATE TABLE new LIKE activity;
ALTER TABLE new ADD UNIQUE(num);   -- in order to catch dups
INSERT IGNORE   -- silently ignore dup nums
    INTO new SELECT * FROM activity
    ORDER BY num, id DESC;   -- same effect as MAX
RENAME TABLE activity TO old, new TO activity;
DROP TABLE old;


Plan C:

ALTER TABLE IGNORE activity
    DROP KEY num,
    ADD UNIQUE(num);


Problem (with Plan C): you cannot predict which of dup rows will be deleted.