reverse_unordered_selects
Make SELECTs without ORDER BY return rows in the opposite of their usual order.
- Default
0 (off)- Range
- 0, 1
- Restart needed
- No
- Default checked on
- SQLite 3.5x
What it does
A debugging switch. If an application breaks with it on, that query was assuming a row order it never asked for. It works for most SELECT statements, but the planner sometimes picks an algorithm it cannot easily reverse, and then the output order stays as before.
Default value
0 (off). Off (a stock SQLite 3.5x build).
Check the current value
PRAGMA reverse_unordered_selects; SELECT * FROM pragma_reverse_unordered_selects; -- table-valued form, usable in queries
Change it
PRAGMA reverse_unordered_selects = ON; -- this connection only
No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.
When to change it
In tests and staging before a release, to flush out queries that lean on natural row order before a schema change or an upgraded build exposes the assumption in production.
What can go wrong
Even with it on, some queries keep their normal order because the planner chose an algorithm that cannot reverse, so a clean run does not prove the application is free of missing ORDER BY clauses; expect reversed results, not an error.
Questions about reverse_unordered_selects
What is the default value of reverse_unordered_selects in SQLite?
0 (off). Off (a stock SQLite 3.5x build).
Does changing reverse_unordered_selects require a restart?
No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.
When should I change reverse_unordered_selects?
In tests and staging before a release, to flush out queries that lean on natural row order before a schema change or an upgraded build exposes the assumption in production.
Back to all SQLite settings, or check the SQLite manual for every option.
Check reverse_unordered_selects on your own server
SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.
Text and data on this page: CC BY 4.0, credit SQLly (sqlly.app). Code and SQL snippets: MIT. License details View as Markdown