# threads

> How many auxiliary worker threads one connection may start to help run a query.

Source: https://sqlly.app/sql-configuration/sqlite/threads
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 (no worker threads)`

**Range**

0 or more threads

**Restart needed**

No

**Default checked on**

SQLite 3.5x

## What it does

The main user is the sorter behind ORDER BY, GROUP BY and CREATE INDEX. 0 keeps everything on the calling thread. The value sets the per-connection SQLITE_LIMIT_WORKER_THREADS limit; SQLITE_DEFAULT_WORKER_THREADS can set the default at compile time and SQLITE_MAX_WORKER_THREADS caps how high it can go.

## Default value

`0 (no worker threads)`. 0 (a stock SQLite 3.5x build) unless the build sets SQLITE_DEFAULT_WORKER_THREADS.

## Check the current value

```
PRAGMA threads;

SELECT * FROM pragma_threads;   -- table-valued form, usable in queries
```

## Change it

```
PRAGMA threads = 4;   -- 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

On multi-core machines that run big sorts or build large indexes and can spare the cores; small values such as 2 to 4 are the usual starting point.

## What can go wrong

Worker threads duplicate sort buffers and compete with the application for CPU, so on a busy server they can worsen overall latency while speeding up one sort. The limit is per connection, so every pooled connection gets its own allowance.

## Questions about threads

### What is the default value of threads in SQLite?

0 (no worker threads). 0 (a stock SQLite 3.5x build) unless the build sets SQLITE_DEFAULT_WORKER_THREADS.

### Does changing threads 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 threads?

On multi-core machines that run big sorts or build large indexes and can spare the cores; small values such as 2 to 4 are the usual starting point.

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

- [`cache_size` Page cache size for this connection: positive numbers are pages, negative numbers are KiB.](https://sqlly.app/sql-configuration/sqlite/cache-size)
- [`temp_store` Where temporary tables and indexes go: compile-time default, file or memory.](https://sqlly.app/sql-configuration/sqlite/temp-store)

## Related on SQLly

- [SQLite query performance troubleshooting Performance guide](https://sqlly.app/sql-performance/sqlite)
