Matheus Epifanio
Matheus Epifanio

Reputation: 113

Running multiple queries on linked servers with sqlalchemy

There are ~150 linked servers and I have to run a query in each linked server. I have to run this as fast as I can.

The way I'm doing today:

def get():
    p = Pool(20)
    stores_sales = p.starmap(function, parameters)
    p.close()

def funtion(parameters):
    engine = create_engine(connString)
    connection = engine.connect()
    session = sessionmaker(bind=self.engine)
    connection.execute(query)
    connection.invalidate()

The problem is that TI guys still want that we make less connections. If we reduce the number of pool (from 20 to 10, for example) we lose a lot of performance if we do that.

I'd like to know if there is a way to run theses queries in parallel using one connection? Or if you have any other suggestion?

Upvotes: 0

Views: 222

Answers (0)

Related Questions