OK maybe I’m a bit hysterical about performance, but I don’t see any reason to have more than double the post entries I need in my database.
I mean every image automatically creates an attachment type post. In my case this means that although my “real” posts are 500, I have like 1500 post entries in my database, most of them being “attachment” posts. Will anything bad happen if I manually delete these attachment post entries (not the actual images) from my database?
WordPress categorizes every upload as an
attachment post-type which is built into your install by default in a similar manner as Pages, Posts, or Comments. If you delete row upon rows of
attachment post types in your database you will lose availability to these in the Media Module ( Add Media button ) and won’t be able to edit the information ( title, alt, caption ), permanently delete, or attach the files onto additional posts. It will forever be lost in your
/uploads/ folder with only a link in your post ( If you attached your file to a post ).
Imagine down the line your website is up and running for 10+ years and you want to go through and remove any old and unused media from your website and server. This can be easily done from the admin panel since WordPress knows ( using the database ) what files are attached to where by using
post_parent. If you remove this database link you’ve orphaned your files onto your server and will need to reverse engineer what files are connected to what posts or if they’re connected to a post. You would spend years making charts and graphs stringing together what goes where and if you’ll need it again eventually spiraling into madness.
In short, it’s very unwise to delete these from the database and not get rid of them on the website. MySQL is extremely powerful and unless you have mountains of images and millions of rows then the actual speedboost you get from deleting these rows would probably be minimal.
TL;DR Stop it, don’t!
Deleting the attachment post columns will potentially affect WordPress recognising that the images exist – they’ll still be stored in your /uploads/ directory, but may be unavailable for use within core WordPress functions.
You will basically kill anything related to the media library and many many other features.