daemon-rewrite/contrib/mysql: Improve cleanup procedure's performance (WIP)