Time to produce "Duplicate Media Files" page
-
I tried your plugin on my test site which is a clone of my non-profit site with over 30,000 media images.
The initial activation showed the process of indexing the media files to add “mdd_hash” to wp_postmeta and that took some time as expected.
When the progress reached 100% everything seemed to stall, but checking the database I saw a long process which was the code that produces the duplicate media page.
I let it run and found it took 4 hours in my case. When looking at your SQL statement which is certainly correct, I though there might be a quicker method. I did find one which took a few seconds to run by changing your $sql in function “get_duplicate_ids” to this:
$sql = "SELECT DISTINCT p.post_id FROM $wpdb->postmeta AS p JOIN ( SELECT count(*) AS dupcount, meta_value FROM $wpdb->postmeta WHERE meta_key = 'mdd_hash' AND meta_value != '" . self::NOT_FOUND_HASH . "' GROUP BY meta_value HAVING dupcount > 1 ) AS p2 ON p.meta_value = p2.meta_value ;";
I don’t see anything wrong with my query, so hope it is usable for your plugin.
I tested “add new media” with duplicates and verified it will not allow any new ones.
Your plugin is very useful to me and also a good example of good coding techniques.
- The topic ‘Time to produce "Duplicate Media Files" page’ is closed to new replies.