Mysql internal Default sort

Source: Internet
Author: User

MySQL default sort:

https://forums.mysql.com/read.php?21,239471,239688#msg-239688

    • depend on order when order by is missing.

    • Always specify order by if you want a particular order – in some situations the engine can eliminate the order by because of how it does some and other step.

    • GROUP by forces ORDER by. (This was a violation of the standard. It can be avoided by using the ORDER by NULL.)

SELECT * FROM tbl--This would do a "table scan". If The table has never had any deletes/replaces/updates, the records would happen to is in the insertion order, hence what You observed.

If you had do the same statement with an InnoDB table, they would has been delivered in PRIMARY KEY order, not INSERT O Rder. Again, this is a artifact of the underlying implementation, not something to depend on.

Https://stackoverflow.com/questions/8746519/sql-what-is-the-default-order-by-of-queries

Mysql internal Default sort

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.