Hi pang,
Do you have iRedAdmin-Pro? if so, please simply execute file shipped within it:
# cd /path/to/iRedAdmin-Pro/
# python tools/cleanup_amavisd_db.py
It may take a long time if you have many records in 3 tables: msgs, msgrcpt, quarantine.
If you're not running the latest iRedAdmin-Pro, please mail us (support at iredmail dot org) to get download link.