Ok, I'm going to wayyyyyyyyyyy oversimplify here.

[oversimplify]Optimize is like a defrag, it retrieves all the emtpy space that can form in a table or tables that have a lot of deletes.[/oversimplify]


[even bigger oversimplify]Analyze, on the other hand decides the order in which tables should be joined[/oversimplify]

Really you should read the annotated documentation at mysql.com for this, as my oversimplifications don't actually do the proper answers any justice at all.

Now, one thing you really want to note is that optimize puts a lock on the tables while it rewrites them. depending upon whether you're using INNODB or MYISAM it could be read or write. This means that a table might, and probably will, be completely useless while the optimize is running. Consider that if you have a rather large messages table and plan accordingly.



This thread for sale. Click here! [Linked Image from navaho.infopop.cc]