Mass delete Github Workflow Run Logs with this script

Github workflow doesn’t allow mass deletion of Workflow Action run logs, it takes 2 clicks to delete each run log.

If you wanted to delete hundreds of these, the only way is to script something.

Luckily you can do so using the gh Github Command Line Tool and some json parsing using the jq tool.

gh – brew install gh
jq – brew install jq

This is how a successful run is supposed to look like, it will delete 30 logs at the time:

Fix high CPU usage by WordPress and MySQL

Today one of our wordpress sites had very high server load and it was being caused by MySQL

So I went to the mysql console, and looked up the process list:

So this guy is appearing a lot
SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes';

Let’s see how it’s behaving with explain
explain SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes';

It’s scanning 226k rows to get its search results!

Probably some moronic plugin is doing this and wordpress does not add an index on that table. The solution is simple, let’s add an index!

ALTER TABLE wp_options ADD INDEX (`autoload`);

Now let’s run explain again

From scanning 226k it went down to 408!, 3 orders of magnitude drop.

And now the CPU load went below 4%, crisis averted.