Today’s discovery. If you’ve had WordPress installed and running your website for more years that you care to think about, and have been through a lot of different plugins and themes over the years, your database is probably full of crap.
It should have 12 tables. Just 12. And the wp_options table should have a few hundred rows in it. Many plugins merrily create new tables that get left behind when you delete them. This is a bit untidy, but usually not too much of a problem.
What is a problem is the wp_options table. Orphaned records get left in there too, and it turns out that WordPress really doesn’t like it having thousands of rows (mine had over 5000). The only option is to delete everything with an option_name containing %transient% and then work through the table deleting groups of entries that aren’t used any more. I suppose you could change the indexing, but that’s really just brushing the problem under the carpet and ignoring the big lump in the middle of the room.
I got mine down to under 1000 rows fairly easily, and got a lot of performance back.
Jetpack is also a bit of a dog. I ditched that too.