Just listing a few useful MySQL Queries I use all the time to maintain my databases. They are all mainly about keeping track of database size and performance.
The following gem returns all databases and their physical sizes and free space available. querying information_schema in this manner is always slow so watch out when you run this.
SELECT
table_schema db_name,
sum( data_length + index_length ) / 1024 / 1024 db_size_MB,
sum( data_free )/ 1024 / 1024 free_MB
FROM information_schema.TABLES
GROUP BY table_schema;
The following gem returns the top 10 largest tables across all databases. I found it in the MySQL Performance blog, and it’s safe to say I use it all the time. The query is quite heavy on large databases, and may take a while to return your results as the above, so don’t use it in the middle of the day during business hours unless you want your sites to run slowly.
SELECT
CONCAT(table_schema, '.', table_name) table_name,
CONCAT(ROUND(table_rows / 1000000, 2), 'M') total_rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') total_data,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') total_index,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
CONCAT(ROUND(data_free / (1024 * 1024), 2), 'MB') total_free,
ROUND(index_length / data_length, 2) index_to_data_ratio
FROM
information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
The following lists all collation and character sets of all tables on all databases.
SELECT
CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) table_name,
CHARACTER_SET_NAME, TABLE_COLLATION
FROM INFORMATION_SCHEMA.TABLES
INNER JOIN INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY
ON (TABLES.TABLE_COLLATION = COLLATION_CHARACTER_SET_APPLICABILITY.COLLATION_NAME)
WHERE
TABLE_SCHEMA NOT IN ('mysql', 'INFORMATION_SCHEMA')
ORDER BY TABLE_SCHEMA ASC, TABLE_NAME ASC
Lists active processes. (MySQL > 5.1)
SELECT * FROM information_schema.PROCESSLIST WHERE COMMAND != 'Sleep'
Slow running queries. (MySQL > 5.1) You may kill any processes with the “KILL” command and the ID
SELECT
ID, INFO, USER, HOST, TIME
FROM information_schema.PROCESSLIST
WHERE
COMMAND != 'Sleep' AND TIME > 4
ORDER BY TIME DESC;
How to offer personalized sms alerts from your site or service

Want to offer personalized sms alerts to your site users? Here is a quick how to.
Receiving instant alerts when an important event happens is always useful. Below is a list of known email sms gateways that you can use to convert an email to a text message:
AT&T: <cell phone number>@txt.att.net
Sprint PCS: <cell phone number>@messaging.sprintpcs.com
Verizon: <cell phone number>@vtext.com
T-Mobile: <cell phone number>@tmomail.net
Virgin Mobile: <cell phone number>@vmobl.com
Nextel: <cell phone number>@messaging.nextel.com
Boost: <cell phone number>@myboostmobile.com
Alltel: <cell phone number>@message.alltel.com
US Cellular: <cell phone number>@email.uscc.net
MetroPCS: 1<cell phone number>@mymetropcs.com
By replacing <cell phone number> with a cell phone number you can send an email to just about any cell phone. Also, you should keep the text as short and concise as possible, as I’ve noticed some carriers(I’m looking at you AT&T) will split longer messages into several text messages, which might be quite annoying.
I use it to receive server temperature alerts at work when our server room starts getting too hot, which should never happen under normal circumstances but does happen when AC fails to cool the room on hot summer days.
You can also use it to offer personalized sms alerts for your website services and such. But you’ll either have to ask your users for what cell phone service they use or send the email to all the gateways at once.
Another use is to forward your google alerts to your cell phone. You can setup a filter in your google email account that will forward all google alerts to your cell phone. This is an excellent way to keep up to date on your website SEO, if you are tracking which websites mentions your domain, blog or whatever.
If you have a shopping cart, you could also offer to send a text message to your customers when the item(s) they purchased has been shipped to them. That’s just another little way to wowing your customers I think.
Here is Wikipedia’s expansive list of known SMS Gateways: http://en.wikipedia.org/wiki/List_of_SMS_gateways.
Now go find ways to flood your cell with alerts, and let me know of other cool ways to use sms.
