Cleaning up a WordPress wp_options table bloated with transients

I’ve got a pair of wordpress sites under my care that have an issue with the wp_options table getting bloated. I mean, really big. Millions of rows for a modest sized site. I suspect it has something to do with the Yoast plugin but I’m not 100% sure. At some point I need to figure out WHY this happens but in the meantime I’ve just been treating the symptoms, so to speak. Every month or so I go in and clean up the tables.

Basically what is happening is that a bunch of transient records aren’t expiring or getting deleted or whatever they are supposed to be doing.

Live example from one of these sites (which, I should add, is running on MySQL)

select COUNT(*) from wp_options

I’ve actually seen it bigger.

So how many of these records are transients?
select COUNT(*) FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%')

So all but 9,771 rows are transients. Even 10K rows seems pretty big for wp_options but for now I’ll pick my battles.

So time to clean up. Step 1 is always to backup the database first, or AT LEAST backup the wp_options table. I prefer to wait to do this late at night or very early in the morning, just in case it impacts performance.

Once you have a backup, do the cleanup
DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%')

Then recheck the count:
select COUNT(*) from wp_options

Much better. And now we’re set for another month or two.

As I said, I’ve been having to do this for a couple sites for a while now, and so far haven’t seen any negative impact from nuking the transients, but as always, I don’t assume responsibility for any damage you cause to your site!

Working remotely

A few years ago we decided to escape the high cost of living in the Boston area and move south. Wound up in Raleigh, NC. Once we’d decided to move I asked my manager if I could work remotely. He said he was willing to give it a try. Honestly I was hoping I could get 6 months or so out of the deal: enough time to find local work.

Four or five years later, I’m still working remotely and couldn’t be more grateful for it. I haven’t set foot in the home office for years.

The up-sides of working remotely are obvious: no commute, you have complete control over your working environment and you, in theory, can work in your PJs. (I don’t, though. I find that ‘getting dressed for work’ is a ritual that helps flick my brain over into working mode.)

There are some downsides, of course. I miss out on a lot of back-channel communications; those “over the cubicle wall” meetings that happen spontaneously and which co-workers often overhear. Conference calls aren’t great when you’re the only one on the phone; it can be hard to hear what’s going on and I’m always aware that I’m inconveniencing my comrades when they need to set up a call just for me.

I actually spend more hours in front of my PC than I did when I worked in the office because I don’t have the distraction of chatting with co-workers or walking across the street with them to get a coffee.

Also while my manager is cool with me working remotely, the owner of the company and a couple of the highest-level execs don’t trust remote workers. They assume anyone who works remote is just goofing off. Because of this, I’m pretty anal about being available all day, every day. That means replying to emails or chat messages as soon as they come in, whenever possible. Still, it’s a small price to pay.

Since I’m the only member of my team that is remote, I don’t work unusual hours. I start at 8:30 or so and work until 5. I usually take a break at 5 to walk the dog then come back to finish up any lingering work that either won’t wait until tomorrow, or that is stuck in my craw and is going to distract me until I finish it.

I also have to be self-reliant. If I’m having a problem with hardware, I need to be able to fix it myself. In theory I guess I could ship my laptop back to the home office and ask IT to remove a virus (or whatever); I know there are less technical remote workers that do that. Our one IT person is over-worked enough without my doing that, so I go to great lengths not to ask for help. As a web developer I feel like you should be able to fix your own issues anyway (short of actual hardware failure, of course).

I use a couple of different systems so that if a problem crops up on one and I can’t fix it quickly, I can switch to working on another system until I have time to address the problem.

I do have a proper desk set up and I spend 95% of my time sitting there working. Every once in a great while I’ll feel the need for a change and I’ll take the laptop and sit on the couch in the living room, or even out on the balcony (though in NC there’re about 10 days out of the entire year that are warm enough to sit outside without being uncomfortably hot).

My Internet connection is 200 MBPS down/ 20 MBPS up. It’s effectively faster than the Internet I had at the office (theirs is faster but of course a lot more people are using it). Fortunately it’s pretty reliable. For a few years I paid for a back-up cellular system but I very rarely had to use it and when I did it was horribly slow. So now on the rare times our Internet goes out, if I don’t have any strictly local work I can focus on, I just take PTO.

Of course the very best part of working from home is my morale officer. She spends most of the day laying on the floor in the office, but if I’m getting stressed or frustrated I can always count on her to make me laugh or smile. Every office should have a dog.

ConEmu – a better Windows terminal experience

I’ve been working in terminals a lot lately. I decided a while back to learn Docker because I needed a better way to host all my dev sites than trying to cram them all onto one old PC running Linux, and Docker seems to be the ‘hot’ container system these days. Or one of them anyway.

I’ve got both Bash for Windows (the Ubuntu subsystem introduced a while back) and Git Bash on my machines and kind of bounce back and forth between them.

When I’m on a laptop I really prefer keyboard shortcuts to using the trackpad for stuff, but I couldn’t get simple stuff like Paste to work in Bash for Windows. I tried everything, CTRL-V, CTRL-SHIFT-V, SHIFT-INSERT, right-clicking.

Eventually I stumbled on the suggestion to just use ConEmu and it has solved all my problems and added some nice features like multiple tabs. It’s kind of a wrapper for other terminal programs so when you open a tab you can have it run Bash for Windows, or Git Bash, or Powershell, or even a Chocolately tab.

It’s free, works great. Ideally I would have preferred not to have to install something new but in this case it seemed like a worthwhile compromise.

I installed it from the site, but you can get it through Chocolately too:

choco install conemu