How to append values to an array in bash

Last week I was working on a bash script for a project at work. The script parsed through a log file with server load and disk usage statistics at regular intervals. The script was calculating the average CPU idle time, disk utilization, and disk usage for servers. After calculating the averages for each of these three metrics, I then proceeded to loop through all the lines in the file and create an array of all the times when the CPU idle time was below average, or the disk utilization or usage was above average.
Read the rest of this entry »

Improve Your WordPress Blog’s Performance With this Database Hack

**UPDATE**: After further research of the query below, I have found some additional information. The query was first introduced in WP 2.3 and is used for comment flood protection. I am currently running WP 2.9.1 and do not have the issue as the query has been modified and using a proper index to assist with the query speed. If you are using the latest version of WP, you won’t have this problem. I am still trying to find exactly when the query was changed so you all can know where you stand. However, I know that some people don’t upgrade their WP version due to changes they have made which upgrading will break. If you are on an older version of WP and have a large number of comments (tens to hundreds of thousands), this query will help improve your comment post times. If you are familiar enough with MySQL, look at the wp_comments table in your database. If there is an index on the `comment_date_gmt` column, you are ok. If not, read on, and run the query below as adding an index to the `comment_date_gmt` column won’t work as your query does not have that column in it’s WHERE clause.

One of daily responsibilities as a database administrator is maintaining the health of our shared hosting environment. In doing so, I deal with plenty of WordPress blogs daily. The one thing I have noticed is that many WordPress plugins are very poorly designed and can cause problems in a shared hosting environment. WordPress at it’s core though, is very well designed, although I have noticed some areas of possible improvement. As I come across common issues, I will post the fixes for them here for all to use.
Read the rest of this entry »

What does “Impossible WHERE noticed after reading const tables” mean?

When it comes to basic query optimization and analysis, in my opinion, there is no better tool than the MySQL EXPLAIN command. It can prove to be an invaluable tool for deciphering the MySQL query execution plan, or the way that MySQL is optimizing and executing the query. It will show you the type of SELECT being made on the table, the join type, possible keys, used keys, rows analyzed and more. I won’t get into the nitty gritty of EXPLAIN in this post, but if you are using it, on occasion you may get the following output:

+-----------------------------------------------------+
| Extra                                               |
+-----------------------------------------------------+
| Impossible WHERE noticed after reading const tables |
+-----------------------------------------------------+

Read the rest of this entry »

Check out Google’s new search interface and try it for yourself

I came across a post the other day about a new Google Interface in development and tried it out for myself. I have to say, it’s not bad. If you look at the screenshots below, you’ll see that the home page is using a bit brighter colors, as well as some subtle gradients, and the colorizing of the input buttons instead of the standard gray. The differences on the search results page are obvious. Again, the colors and gradients, as well as a strong font in the search box and additional search options on the left side of your results. The screenshots below have the old interface on the left and the new interface on the right.
Read the rest of this entry »

mysqldump: Got error: 2008: MySQL client run out of memory when retrieving data from server

I came across this error today while at work. While trying to process a MySQL dump of a database of approximately 8 GB in size, I got the following error:
mysqldump: Got error: 2008: MySQL client run out of memory when retrieving data from server
This occurred on a MySQL 4.1 server. To get around this, you will need to use the -q switch as part of your mysqldump command.

This option is useful for dumping large tables. It forces mysqldump to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out.

(source: MySQL :: MySQL 3.23, 4.0, 4.1 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program)

Your full command should look something like this:
$ mysqldump -u user -p password -q database > outfile.sql

12 Quick and Easy MySQL Tricks

In my first two months as a MySQL DBA, I have picked up a number of tips and tricks that have helped me in my daily job. In this post, I share them here with everyone. Hopefully they will help you as much as they have helped me.
Read the rest of this entry »

Top 20+ MySQL Best Practices

I came across an excellent article a couple days ago in my NetTuts+ RSS Feed titled “Top 20+ MySQL Best Practices”. In the article, author Burak Guzel gives some excellent MySQL tips. Due to my argumentative nature (not really) I made a few comments on the post that you can see at the bottom about 1 or 2 of the tips. The tips were by no means wrong, I just wanted to add some clarification and caveats to them. A couple of the tips, I have been using every single day in my job and they have proven invaluable. The article is excellent and I highly recommend reading it.
Read the rest of this entry »

Where do you find your reading material?

Anyone who is at the very least semi-serious about growing their blog, or learning more about their subject, knows, you never stop reading. There is always something on the internet worth reading in your niche and anyone who says otherwise is either a liar, in denial, or not looking hard enough to find it. The information is out there and it won’t come to you, you have to go and find it.
Read the rest of this entry »

Avoid WordPress StatPress plugin like the plague!

The WordPress plugin StatPress is an absolutely horrid plugin to use. Yes, I said it…horrid! After seeing many people praising this plugin on their sites, this is a bold statement.
Read the rest of this entry »

Temporary Tables are Bad!

This article was written by a co-worker of mine and I wanted to share with everyone else.

Temporary Tables. What are they? Why are they bad? You might think you don’t explicitly use any, but in actuality you may be using them all the time.

Temporary tables come in two flavors. The kind you know you’re making, and the kind you don’t. You know you’re making a temporary table when you use the CREATE TEMPORARY TABLE syntax. On the other hand, there are lots of other cases in which MySQL will create a temporary table for you, in the background, to help out the query execution to get you your results.
Read the rest of this entry »