Skip to contents

Manually applies sx resource limits (threads, memory) to a given DuckDB connection.

Usage

sx_limit_duckdb_conn(conn, threads = NULL, memory_limit_gb = NULL)

Arguments

conn

A DuckDB connection object (from DBI::dbConnect).

threads

Integer. Number of threads to use. If NULL (default), uses the global sx.duckdb.threads option. Providing a value pins the connection.

memory_limit_gb

Numeric or character. Memory limit to use. If NULL (default), uses the global sx.duckdb.memory_limit_gb option. Providing a value pins the connection.

Value

Invisibly returns the connection.

Details

When threads or memory_limit_gb are explicitly provided, the connection is "pinned" in an internal registry. Pinned connections are immune to global policy enforcement (see sx_options(duckdb_enforcement_mode = "all")), ensuring that manual engineering decisions are respected.

To unpin a connection and return it to global policy management, call this function without any limit arguments.