Tuesday, 25 January 2011

Webform module out of memory

The webform module will give a PHP fatal out of memory error when downloading and if your result set is rather large ( tens of thousands of records)..

Issue is discussed here, along with patches

Thursday, 13 January 2011

Finding fragmented MySQL tables and optimising them - bash script

Via here


Note: if you just want to find fragmented tables and don't want to optimise, just comment out the "OPTIMIZE TABLE" line in the script below


#!/bin/sh

echo -n "MySQL username: " ; read username
echo -n "MySQL password: " ; stty -echo ; read password ; stty echo ; echo

mysql -u $username -p"$password" -NBe "SHOW DATABASES;" | grep -v 'lost+found' | while read database ; do
mysql -u $username -p"$password" -NBe "SHOW TABLE STATUS;" $database | while read name engine version rowformat rows avgrowlength datalength maxdatalength indexlength datafree autoincrement createtime updatetime checktime collation checksum createoptions comment ; do
if [ "$datafree" -gt 0 ] ; then
fragmentation=$(($datafree * 100 / $datalength))
echo "$database.$name is $fragmentation% fragmented."
mysql -u "$username" -p"$password" -NBe "OPTIMIZE TABLE $name;" "$database"
fi
done
done

Wednesday, 12 January 2011

Find fragmented tables in MySQL

Via Mindraven:

Over time some of your MySQL tables may end up fragmented. If you run any type of diagnostic script like mysqltuner, it will even tell you how many of your tables are fragmented. You can easily fix this by optimizing the fragmented tables. The problem is, you might not know which tables are fragmented.

Here’s a quick little query you can run that will give you the tables that are fragmented and how badly fragmented they are:

select TABLE_NAME, TABLE_SCHEMA, Data_free from information_schema.TABLES where TABLE_SCHEMA NOT IN ('information_schema', 'mysql') and Data_Free >0;

Just in case anyone didn’t catch the optimize bit above. Once you’ve found your fragmentend tables, you can fix them with the following query, replacing %TABLENAME% with the actual table name:

optimize table %TABLENAME%

JMeter and MySQL

Jmeter and MySQL - a How To on installation and configuration.