Optimizing your database removes the gaps in data or "overhead" that can occur when your database works with your website.
This can have the side effect of restoring optimal performance to your website if its database contributes to its slowing. However, optimizing your database does not prevent future slowing because it does not fix the scripting that initially created the overhead.
Before you begin, you need to back up your database. For more information, see Backing up and Restoring MySQL or MSSQL Databases.