Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Do we experience a noticeable difference in performance for these two queries?

INSERT INTO table (col1, col2, col3, col4, col5) ...


INSERT INTO table (col5, col3, col1, col2, col4) ...

Do we need to arrange INSERT columns according to the order of columns in the table?

share|improve this question
Are you suffering from premature optimization syndrome? – Denis Valeev Mar 27 '12 at 17:25
:D something like that! I'm just curious to learn! – All Mar 27 '12 at 17:27
Obviously the order in which the columns are specified doesn't affect performance. Because if you were the compiler you could just rehash the whole thing to represent it in its proper order which the compiler obviously does by matching names with the proper places on the data page. Things are a bit complex on the lower level so do you really think mysql guys messed up with this triviality? – Denis Valeev Mar 27 '12 at 17:32
up vote 8 down vote accepted

No, you don't need to gave the columns in the same order. Not least, table order may not reflect actual on-disk order (this is 100% true for SQL Server, and I'm sure MySQL is the same)

Unless your OCD itch needs scratched

share|improve this answer
Thanks for explicit and informative answer! – All Mar 27 '12 at 17:33
I mainly keep it in the same order for consistency. Copy/paste FTW! – DForck42 Mar 28 '12 at 5:27
@DForck42: agree. Also see my tip here: – gbn Mar 28 '12 at 5:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.