wp_term_relationships millions rows

shaymiller

Regular Member
Joined
Dec 3, 2016
Messages
456
Reaction score
45
my hostgator is telling me that I'm over using my MYSQL resources. I have 5 WP sitess. Most of them are in development mode. One is live. they mention that wp_term_relationships has over 2.8m rows.

can I simply goto phpmyadmin and delete those or should I delete via WP-ADMIN?

It is an auto-blog, I am happy to remove old posts if necessary.

I found this post http://scottnelle.com/648/clean-bloated-wp_term_relationships-table/

I only have 77K posts in WP
 
That's how Wordpress works and that's why my personal opinion is that Wordpress is becoming more and more bloated and ridiculous. 77k posts isn't "just" 77k posts.. every post produces multiple database records and probably that's why you have that many lines in that table.
 
@Diplomat

how can I find out which record does not relate to a post? I did delete 30K post. I'm guessing those 30K post related records are still in wp_term_relationships table. I ran few SQL queries I found on the net about bloated. It found only 2 records.
 
@Diplomat

how can I find out which record does not relate to a post? I did delete 30K post. I'm guessing those 30K post related records are still in wp_term_relationships table. I ran few SQL queries I found on the net about bloated. It found only 2 records.

That post you shared should help you.
 
@Diplomat
to be honest, it wasn't helpful, so I posted here to get some more help. Should I l delete rows from wp_term_relationships table or should I do a query to see, which record does not have a wp_post attached?
 
@Diplomat
to be honest, it wasn't helpful, so I posted here to get some more help. Should I l delete rows from wp_term_relationships table or should I do a query to see, which record does not have a wp_post attached?

Why it wasn't useful? It seems pretty simple there.. First command shows all orphaned relationships, second one deletes it, third one optimizes your database.

Also, MAKE SURE YOU TAKE A BACKUP! Otherwise if you start deleting and then mess up, you can't recover your stuff if there is something gone.

https://wordpress.org/plugins/wp-optimize/

Try this one too.. it removes a bunch of old crap you don't need.
 
Are you assigning categories and tags to each post? If so, how many? Somebody correct me if I’m wrong, but I think that table stores a record for each category/tag assigned to a post. I never found tags to be very useful and only use categories. I also limit each post to a single category because I don’t like having a post getting listed under different categories.
 
Back
Top