I have a call to a 3rd party ODBC driver as follows:
var DbConnection = new OdbcConnection(@"DSN=QuickBooks Data;SERVER=QODBC;OptimizerDBFolder=%UserProfile%\QODBC Driver for QuickBooks\Optimizer;OptimizerAllowDirtyReads=N;SyncFromOtherTables=Y;IAppReadOnly=Y");
var tb = new DataTable();
using (var ad = new OdbcDataAdapter("SELECT * FROM Customer", DbConnection))
{
ad.Fill(tb);
}
It runs from a colsole application fine, takes a few seconds.
But if I change nothing else but run it from a self hosted WCF service like this:
[ServiceContract]
public interface IQuickBooksService
{
[OperationContract]
DataTable GetQuickBooksData(string query);
}
public class QuickBooksService : IQuickBooksService
{
public DataTable GetQuickBooksData(string query)
{
var DbConnection = new OdbcConnection(@"DSN=QuickBooks Data;SERVER=QODBC;OptimizerDBFolder=%UserProfile%\QODBC Driver for QuickBooks\Optimizer;OptimizerAllowDirtyReads=N;SyncFromOtherTables=Y;IAppReadOnly=Y");
var tb = new DataTab开发者_StackOverflow社区le();
using (var ad = new OdbcDataAdapter("SELECT * FROM Customer", DbConnection))
{
ad.Fill(tb);
}
return tb;
}
}
I can see the driver working via a status panel it provides but at a pathetic snail pace.
I'm kind of stumped. Any help is appreciated.
Note: the way I'm going to get around this if I don't solve it is to use the database as a message queue and make the (fast) console app poll for messages and put results back into the database (maybe a temp table, I don't know) by dumping the datatable out to XML.
Perhaps due to the reason you serrialize DataTable that contains much data? If you need to poll database through WCF I would use something lighter than DataTable and consider asynch operations
精彩评论