giordanolima , your question is NOT silly.
The order of the columns may have rather BIG performance impact on some DBMS such as SQL Server
, Oracle
and MySQL
.
This post can serve as a guide for future references. Some conventions may be adopted:
Primary key first
Foreign key second
Frequently searched columns third
Frequently updated columns fourth
Columns with "null" allowed by last
An example of a difference in performance is in the request of an index. The database system finds the row based on some conditions of the index and returns the row address. Now, let's say you're looking for "Idade"
and this is in your table:
Id int,
Nome varchar(100),
Idade int
The system needs to find where Idade
starts, because Nome
has an indefinite position. However, if you change the order to:
Id int,
Idade int,
Nome varchar(100)
Now the system knows that Idade
was found 4 bytes
after the beginning of the line. So the order can have a considerable impact. Yes .