Database Abstraction Layer for PHP

User Tools

Site Tools



Applies To

ADOdb Load Balancer

See Also


 bool $enable_sticky_sessions=true


The public class variable $enable_sticky_sessions pins the execution of commands to the last connection used. The default value for this is true. The normal behavior of the load balancer is to re-use the first found connection, as the overhead of establishing a database connection is generally larger than that of running multiple simple queries against a single connection.

The primary use-case for disabling this is if you are running a substantial number of heavy queries and want to truly load balance at the per-query level rather than the per-request level.

Since connecting to the database can take longer than running a few queries, it is less efficient to startup 5 connections to run 5 separate queries, when all 5 queries could be run on a single connection in less time. However if you need to run 1000 queries in a row (ie: batch job), it might be better to startup 5 connections and load balance all 1000 queries across those connections.


$db->enable_sticky_sessions = false;
v5/reference/loadbalancer/enable_sticky_sessionsl.txt · Last modified: 2017/05/11 01:14 by mnewnham