Skip to content

Configuring DuckDB

DuckDB is the embedded OLAP database used by liwan. The defaults suit most deployments, but you can adjust memory and thread limits for smaller servers or unusual workloads.

By default, DuckDB can use up to 80% of system memory and all available CPU cores. That is usually fine, but resource-constrained systems may need lower limits.

The memory limit of DuckDB can be set using the LIWAN_DUCKDB_MEMORY_LIMIT environment variable or duckdb.memory_limit in the configuration file. DuckDB documents approximately 125 MB per thread as a minimum rule of thumb and recommends 1-4 GB per thread for typical workloads. Reduce the thread count before setting a very low memory limit.

The number of threads DuckDB uses can be set using the LIWAN_DUCKDB_THREADS environment variable or duckdb.threads in the configuration file. By default, DuckDB uses all available CPU cores.

For large queries that do not fit in memory, DuckDB can spill intermediate results to disk. Use local storage for read-write database workloads. Consult DuckDB’s storage guidance before using network-attached storage.