You could also use these scripts:

http://www.ixora.com.au/scripts/query_opt.htm