# reverse_unordered_selects

> Make SELECTs without ORDER BY return rows in the opposite of their usual order.

Source: https://sqlly.app/sql-configuration/sqlite/reverse-unordered-selects
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**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](https://sqlly.app/sql-configuration/sqlite), or check the [SQLite manual](https://www.sqlite.org/pragma.html) for every option.

## Related SQLite settings

- [`automatic_index` Let the planner build a temporary index for a join when none exists.](https://sqlly.app/sql-configuration/sqlite/automatic-index)
- [`analysis_limit` Approximate rows ANALYZE examines per index; 0 means all rows.](https://sqlly.app/sql-configuration/sqlite/analysis-limit)

## Related on SQLly

- [Diagnosing a slow SQL query Performance guide](https://sqlly.app/sql-performance/slow-query)
- [When a fast query turns slow Performance guide](https://sqlly.app/sql-performance/sudden-slowdown)
- [SQLite query performance troubleshooting Performance guide](https://sqlly.app/sql-performance/sqlite)
