Skip to content

Commit 0d9b975

Browse files
committed
Use an ORDER BY clause for user-visible queries
> If sorting is not chosen, the rows will be returned in an unspecified > order. The actual order in that case will depend on the scan and join > plan types and the order on disk, but it must not be relied on. A > particular output ordering can only be guaranteed if the sort step is > explicitly chosen. http://www.postgresql.org/docs/8.3/static/queries-order.html
1 parent ae2f4a3 commit 0d9b975

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

best-practices/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ Postgres
165165
* Consider a [partial index] for queries on booleans.
166166
* Constrain most columns as [`NOT NULL`].
167167
* [Index foreign keys].
168+
* Use an `ORDER BY` clause on queries where the results will be displayed to a
169+
user, as queries without one may return results in a changing, arbitrary
170+
order.
168171

169172
[`NOT NULL`]: http://www.postgresql.org/docs/9.1/static/ddl-constraints.html#AEN2444
170173
[combines multiple indexes]: http://www.postgresql.org/docs/9.1/static/indexes-bitmap-scans.html

0 commit comments

Comments
 (0)