I can't comment on your first two questions, but my technique while developing my recent Amavis / SpamAssassin / Postfix / Dovecot installation was three fold.
1) Enable logging of MySQL queries...
general_log=ON
general_log_file=/var/db/mysql/mysqld-queries.log
slow_query_log=ON
slow_query_log_file=/var/db/mysql/mysqld-slow-queries.log
log-output=TABLE
expire_logs_days=1
I initially had MySQL log to a file, but the formats not very easy to read so I looked into and converted to logging to table. Logging to SQL gives you the ability filter by date/time, user/host, command type as well as the SQL command its self. The general_log_file line isn't required in my setup any more, its just there for historical reasons.
** WARNING ** Enabling logging on a busy system will quickly fill up your disk. My MySQL server can log about 5GB a day. Also, there is also a big IO performance hit when enabling MySQL logging.
After trial and error I've settled on executing "TRUNCATE TABLE general_log" on a nightly basis to keep my logging under control. I leave my slow_query table along as it seldom gets anything, but its handy to keep an eye on it in case you do have a query that takes a long time.
Further food for thought
www.oreillynet.com/databases/blog/2007/05/hacking_mysql_table_logs.html
2) Obviously best practice anyway, but I made every application use a different mysql username. This allows me to filter my general_log by application very quickly.
3) I added comment's to the SQL commands my application was using, if the application allowed me to alter the SQL commands the application used.
For example, here's my
relay_domains.cf for postfix.
SELECT domain AS virtual FROM postfix_virtual_domains WHERE domain='%s' AND active = 'y' /*
relay_domains.cf */
Good luck!
Steve
> To:
amavis...@amavis.org
To:
ma...@marc-stuermer.de
amavis...@amavis.org
DISCLAIMER
This email is for the use of the intended recipient(s) only. If you have received this email in error, please notify the sender immediately and then delete it.
If you are not the intended recipient, you must not keep, use, disclose, copy or distribute this email without the author’s prior permission.
We have taken precautions to minimise the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message.
We cannot accept liability for any loss or damage caused by software viruses.
The information contained in this communication may be confidential and may be subject to the attorney-client privilege.
If you are the intended recipient and you do not wish to receive similar electronic messages from us in future then please respond to the sender to this effect.