The best way to optimize a database is by using indexing in database.
Indexing is a internal mysql feature which helps the retrieving data quickly from databases. It works like an index page in book. Where anybody can look for the heading and retrieve the need information quickly.