The most important thing but often forgotten is INDEXING.
Imagine your table has 1.000.000 records. MySQL block can contain 5 records, so you have 200.000 blocks in storage system.
When you select a row in table, it means you need to find an record in 200.000 blocks.
If each accessing to block take 0.001s and your wanted record in the block 200.000th, so it will take 0.001 x 200.000 = 200s <=> 3 minutes. Quite slow.
(Actually it's not straight forward like this formula because file-system use sequential access when scan all table, so it save I/O time then total time in fact is less than 3 minutes).
But if we have an index in this table:
It's possible to create many index in table but we all know index is store in B-tree structure and MySQL when process query will optimize to choose which the best index to use. So, the more index in your table, the more space need to be allocate to store index , the more time to optimize.
Consider indexing in which column:
(col1, col2, col3)
, you have indexed search capabilities on (col1)
, (col1, col2)
, and (col1, col2, col3).