To optimize the database of your Drupal script, you can install the module DB maintenance.
Step 1: You can find more information about DB maintenance module and download it from the following link:
https://www.drupal.org/node/41588
Step 2: Once the installation is completed, you can optimize your Drupal database from the administrative area of your application > Configuration > System > DB maintenance