How do you optimize a MySQL database for performance?

Additional structures like materialized views can help you keep good statistics about the queries you're running and they cache execution plans better than plain indexes. So if it is not too much to maintain them you can use them.

Run your queries on a sample dataset with cache disable and the explain plan flag. This will help you appreciate what the Db is executing when resolving your information for the first time the operation arrives.

Full scan operations and cross joins are candidates for optimization. In general, it's a good practice to build indexes over the fields you have in your where clauses so the db doesn't have to go to disk to know which records matter. Sometimes you can even add the select clause columns to the index and still make the index fit in memory.

Query rewriting is another option, like only including in the select projection the columns that are important to the information requirement. Sometimes using UNION is faster that wheres with ORs and bitmap indexes are better that equals expressions on enums. These are just some techniques, and they always require some degree of analysis. So it really comes down to studying what are your queries causing the db system to do.

Additional structures like materialized views can help you keep good statistics about the queries you're running and they cache execution plans better than plain indexes. So if it is not too much to maintain them you can use them.

Caching and parametrizing caching might also help for cases when you run the same query every time just with different parameters. I am not a big fan of this strategy , since caches in the db are usually temporary and quickly flushable. Indexes, in my opinion are the real solution to query slowness.

Read with no lock by default. Use lock for update when it is strictly needed.

Also, try to have a decent updated set of statistics on your columns. Like your high selectivity operators, count your nulls. This will help your structure your queries more efficiently. For example: If you know for sure the max value of a number in your domain is 200 would you reserve 10 digits or 3 to store it?. That's the beauty of good statistics, they make you think about resources.