Optimise wordpress database using SQL after deleting registered images from Media Folder


I have used Media Cleaner Pro Plugin to clean few batches of registered images. Additionally i have updated my functions.php so these unused images will not be generated in future.

function wpse_unset_images( $sizes ){
unset( $sizes[ 'medium_large' ] );
unset( $sizes[ 'large' ]);
unset( $sizes[ 'member-two' ] );
unset( $sizes[ 'member' ] );
unset( $sizes[ 'shop_thumbnail' ]);
unset( $sizes[ 'woocommerce_gallery_thumbnail' ] );
unset( $sizes[ 'widget-thumb-medium' ] );
return $sizes; 
add_filter( 'intermediate_image_sizes_advanced', 'wpse_unset_images' );

I can clearly see the visible difference in my web space which has reduced from 7GB to 4GB and also indoes has come down to half from almost 300,000 to 1,70,000.

But i have seen that there is no difference in DB size. It means plugin has NOT removed required rows/data from database. Database size is still 350MB.

I have around 12K products, but having almost

  • 700,000 rows in wp_postmeta
  • 80K rows in wp_options
  • 40K rows in wp_posts

I need some guidance to clean/optimize database using SQL to remove data related to removed images.

NOTE* – Additional rows in DB may also be due to fact that i updated product prices in BULK for almost 12K products twice. I need to clear that mess also.

kandav 2 years 2020-12-18T23:10:43-05:00 0 Answers 6 views 0

Leave an answer