# Ensure The Order Of Returned Results

__*Ensure result order*__

+ `ORDER BY`
+ You need to pay attention to the distributed behavior of distributed systems


![left](./student-guide/diagram/tidb-computing-dist-sql-flow.drawio.png)

------------------------------------------------------------
In the semantics of SQL, the sequential output of the result set is guaranteed only if the order by syntax is used. Since the data is stored on a single-instance server, the results of multiple executions are often stable without data reorganization. Some databases (especially the MySQL InnoDB storage engine) also output the result set in the order of the primary key or index. TiDB is a distributed database where data is stored on multiple servers. In addition, the TiDB layer does not cache data pages, so the result set display order for SQL statement without order by is easily perceived to be unstable. If you want to output the result set in order, you need to explicitly add the column you want to sort in the order by clause, which is in line with SQL semantics.

From business logic, the result can only be unique if the order by column combination is guaranteed to be unique.