Limits: Understanding Apex SOQL connection pool scaling with concurrent transactions
0 reputation · 15 Jan 2022, 17:31 UTC
0 reputation · 15 Jan 2022, 17:31 UTC
Goal: Clarify whether the Apex runtime’s shared database connection pool, which is consumed one connection per SOQL query, adjusts its capacity based on the number of concurrent transactions or remains a fixed org‑wide allocation.
Context: Each synchronous Apex transaction is limited to 100 SOQL queries, each query borrowing a connection from the pool; the pool is released only when the transaction ends. Asynchronous executions (Batch, Queueable, Future) have independent limits and pool usage per chunk. Documentation notes that exceeding the SOQL limit can appear as intermittent connection pool exhaustion but does not specify whether the pool size scales with load or is static.
33275 reputation · 15 Jan 2022, 23:44 UTC
No. Apex does not expose a customer-managed SOQL connection pool that scales with concurrent transactions or is a fixed org-wide allocation you can configure. Database connections are managed internally in Salesforce’s multi-tenant architecture with platform resource governance, queuing and throttling. There is no supported API, setting, or metric for customers to inspect or tune a SOQL connection pool size.
Intermittent “pool exhaustion” symptoms with concurrent load are typically per-transaction governor limit hits, org concurrency throttling, or contention from inefficient queries, not exhaustion of a client-side pool. Each query does not permanently borrow a connection for the life of the transaction in a customer-visible way; the platform schedules work internally.
Governor limits and concurrency caps are version-sensitive and can change with Salesforce releases. Treat numeric limits as current-model knowledge and verify in the org.
One missing diagnostic detail that changes the recommendation: the exact error text you are seeing and whether the workload is synchronous user-triggered or asynchronous Batch/Queueable/Future. With that, the guidance can be scoped to bulkification and query consolidation versus async offload.
Use comments to ask for clarification. Post a solution as an answer.
33,275 reputation · 16 Jan 2022, 02:51 UTC
If you hit a runtime error like Too many concurrent connections while running many synchronous Apex transactions, the issue is the static SOQL connection pool, not a per‑transaction limit.
Event Log Files for events of type DatabaseConnection; the ActiveConnections field caps at the same value across concurrent runs.Limits.getLimitDatabaseOperations() in a debug log to see the org‑wide cap (typically 1000 in production).Async jobs share the same static pool but have separate per‑chunk limits, so the pool size is never auto‑scaled by concurrent load.