Chloe
Chloe copied to clipboard
Command queuing/ how to make thousands of queries?
Hi
I have been using Chloe very successfully, well done. However, if I want to queue lots of simultaneous queries I run into some trouble
public void deleteAttributes()
{
foreach (var attribute in Products.attributes)
{
_ = Task.Run(() =>
{
//remove from database
_ = Task.Run(() => DB_DeleteProductAttribute(attribute).Wait());
});
}
}
public async Task<bool> DB_DeleteProductAttribute(product_attribute attribute)
{
using (IDbContext context = new MySqlContext(base.GetConnectionMain))
{
var rowsChanged = await context.DeleteAsync(attribute);
return rowsChanged > 0;
}
}
It will do some requests but then I quickly run into "All pooled connections are in use" exception inside Chloe. I want deleteAttributes to execute quickly and then the queries should be executed in the background by tasks.. this code used to work fine with Dapper, I dont know how to fix it and would appreciate some advice.
What is the configured connection pool value in the database connection string?
@shuxinqin I dont have any connection pool value currently configured in the connection string. However shouldnt it use whatever the max pool value is and queue the rest of the commands?