useBackgroundIsolates property

bool useBackgroundIsolates
final

Whether to use background isolates to open database connections and to run queries.

This is enabled by default, and the recommended option for almost all workloads: Because SQLite queries block on synchronous IO, running them in an UI isolate degrades UI performance and can cause dropped frames. Running queries on background isolates also allows reads to run in parallel (see maxReaders), further improving performance for read-heavy workloads.

In special setups, avoiding synchronous IO may not be necessary. If a background isolate spawned via e.g. Isolate.run opens a database, it doesn't block the main thread and synchronous IO may be acceptable there. For these setups, disabling background isolates may be faster (as there is no SendPort overhead).

When this is disabled, statements run synchronously on the calling isolate. This package still uses an asynchronous pool to obtain connections, preventing isolates from issuing writes in parallel (as that would cause SQLITE_BUSY errors).

This option has no effect on the web.

Implementation

final bool useBackgroundIsolates;