(I) any query is annoying.
As long as the query and MySQL are annoying, the fastest way to execute the query is not to execute
Cache is king, such as redis or memcache
(Ii) Minimum query result set
Try to query based on the primary key or secondary index, and avoid returning the table by overwriting the index to save Io
For example:
Select col1 from table where primary_key_column = something;
(3) query with joins
Use appropriate anti-paradigm to avoid join
For example:
Select t2.value from T2 join T1 on (t1.id = t2.tid) Where t1.orderdate = now ()
You can extract the orderdate column in T1 and place it in T2.
Select t2.value from T2 where t2.orderdate = now ()
(Iv) Aggregate Query is the most annoying
Periodic pre-load summary tables to avoid real-time online Aggregate Queries
Using Insert... on duplicate key update is helpful.
By waterbin
2013-07-20
Good luck