I'm thinking this should improve the performance of the delete queries:
where idsite in(...)should only lock rows belonging to that site. New tracking requests for those rows / idsite shouldn't come in cause the site no longer exists (would be discarded by tracker) so it shouldn't be a problem.
Initially I also implemented a check for each table that had
idsite column to check if tracking requests for that site exists and only delete if the log table has tracking requests for that site, but it shouldn't be needed.