Implement random calling of optimized OpenDB with an optional env var

It's a port from 3.2.x to 3.5.x and master.