// sqlite · disk i/o

max_page_count

Cap on how many pages the database file may hold, so it cannot grow past a size you choose.

預設
4294967294 pages
Range
Current page count up to 4294967294
Restart needed
否
Default checked on
SQLite 3.5x

其作用

A write that would push the file past the cap fails with SQLITE_FULL instead of consuming more disk. Each attached database gets its own cap, and the pragma will not set one below the file's current page count. With the default 4KB pages the stock cap allows a file of about 17.5TB.

預設值

4294967294 pages. 4294967294 (2^32-2) since SQLite 3.45.0; 1073741823 before that. With 4KB pages the cap is about 17.5TB.

Check the current value

PRAGMA max_page_count;

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

Change it

PRAGMA max_page_count = 1073741824;   -- 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 volumes shared with other data, such as embedded devices or app-private folders, where one runaway database must not eat the last free disk space.

What can go wrong

Too low a cap fails inserts and updates with SQLITE_FULL, which reads like a full disk even when the volume has room; applications hitting it unexpectedly need the error surfaced clearly so the limit gets raised instead of disk space chased.

Questions about max_page_count

What is the default value of max_page_count in SQLite?

4294967294 pages. 4294967294 (2^32-2) since SQLite 3.45.0; 1073741823 before that. With 4KB pages the cap is about 17.5TB.

Does changing max_page_count 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 max_page_count?

On volumes shared with other data, such as embedded devices or app-private folders, where one runaway database must not eat the last free disk space.

Back to all SQLite settings, or check the SQLite manual for every option.

// one client for every engine

Check max_page_count 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.

本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情