Does the order of columns in a query matter?

后端 未结 3 890
花落未央
花落未央 2021-02-20 04:09

When selecting columns from a MySQL table, is performance affected by the order that you select the columns as compared to their order in the table (not considering indexes that

3条回答
  •  礼貌的吻别
    2021-02-20 04:35

    The order doesn't matter, actually, so you are free to order them however you'd like.

    edit: I guess a bit more background is helpful: As far as I know, the process of optimizing any query happens prior to determining exactly what subset of the row data is being pulled. So the query optimizer breaks it down into first what table to look at, joins to perform, indexes to use, aggregates to apply, etc., and then retrieves that dataset. The column ordering happens between the data pull and the formation of the result set, so the data actually "arrives" as ordered by the database, and is then reordered as it is returned to your application.

提交回复
热议问题