MySQL Forums
Forum List  »  Newbie

Re: insert in an ordered set, then reorder
Posted by: Peter Brawley
Date: October 04, 2016 01:29PM

> Ho[w] to insert/update (orange, 2) before red or after blue? and reorder the set?

Do not try.

A fundamental attribute of relational tables is that physical row order in tables is undefined, that is, the engine is free to order them for its own convenience. For InnoDB, that convenience is defined in something you can't see, the btrees of its keys (indexes).

So, use keys to provide orderings that queries can efficiently execute, eg if a table with PK id will often be queried with an Order By this_column, add index(this_column) to the table.

Options: ReplyQuote


Subject
Written By
Posted
Re: insert in an ordered set, then reorder
October 04, 2016 01:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.