Made each thread open its own connection, which appears to be what pg desires.