Is db_set_active a global or local setting?
It's a per-request global setting. db_set_active calls:

Database::setActiveConnection($key);


Which sets the static $activeKey property of the Database class. 

Database::getConnection(), which is where the connection for all queries comes from, then uses that same static $activeKey.

So once you've used db_set_active, all queries in that request will use the new connection until changed again. 

It doesn't persist across multiple requests.