Database optimization is not at all like machine code optimization. With databases, most of the time when you want to reduce disk I / O and wastefully trying to align the fields, it will make fewer records in the disk block / page. In addition, if any kind of alignment is beneficial, the database engine will do this automatically for you.
The most important thing is indexes and how well you use them. Trying the trick to gather more information in a smaller space can ultimately make it difficult to get good indexes. (Do not overdo it, however, not only indexes slow down INSERT and UPDATE for indexed columns, but also mean more work for the scheduler, which should take all the possibilities into account.)
Most databases have an EXPLAIN command; try to use it when selecting (in particular, with multiple tables) to understand how the database engine works.
Cesarb
source share