ORDER BY NULL in MySQL

后端 未结 5 577
独厮守ぢ
独厮守ぢ 2020-12-23 17:09

What is ORDER BY NULL in MySQL?

Does it decrease the query speed?

5条回答
  •  青春惊慌失措
    2020-12-23 17:40

    Some developers used ORDER BY NULL to increase the speed of the queries using the GROUP BY clause.

    The reason is that prior to MySQL 5.6 there was an implicit sort of the data when calling the GROUP BY clause. So adding ORDER BY NULL was inactivating this implicit sort and consequently making the query run faster.

    Since MySQL 5.6, the implicit sorting of the GROUP BY clause is DEPRECATED http://www.tocker.ca/2013/10/21/heads-up-implicit-sorting-by-group-by-is-deprecated-in-mysql-5-6.html

    Therefore the ORDER BY NULL technique is now useless.

提交回复
热议问题