I just added a folder (containing sub-folders) to my new DB, which now totals 403,312 files. Its first Compact & Optimize operation took about 18 min, as reflected in the file attachment. I'm gonna do it again, but as this is the longest it's ever taken, I'm wondering if the log file has anything to say about it?
Check your virus checker and make sure it leaves IMatch and the database folder (!) alone.