giordanolima, your question is NOT silly.
Column order can have yes GREAT impact on performance in some DBMS such as SQL Server
, Oracle
and MySQL
.
This post can serve as a guide for future references. Some conventions can be adopted:
- Primary key first
- Foreign key according to
- Columns searched frequently third
- Columns updated frequently quarter
- Columns with "null" allowed" by last
An example of difference in performance is in the request for an index. The database system finds the line based on some index conditions and returns the line address. Now, say you’re looking for "Idade"
and this is on your table:
Id int,
Nome varchar(100),
Idade int
The system needs to find where Idade
begins, because Nome
has undefined 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. Then, the order can have a considerable impact yes.
performance interference does not occur in the ordering of tables, because if you have in mind something large voluminous as
bigdata
generally distributed in nodes(clusters) that maximize processing, the database is designed to store read data and tables independent of format and order. your question suggests a very long answer, more summarizing, does not interfere.– Hebert Lima
Thanks @Hebertdelima... That was great...
– giordanolima