Wednesday, March 21, 2012

OLEDB query responsiveness vs. .NET/SQL Server Management Studio

I am using OLEDB in C++ and the ATL templates to access a Compact Edition database and SQL Server Management Studio to test queries on it.

The problem I'm having is that SQL Server Management Studio seems to have much better query responsiveness (time to display of first result) than OLEDB, which sort of invalidates my reason for using Studio. Specifically this is the time to just return from ICommand::Execute.

Does .NET (which I assume Studio is using) have an advantage over OLEDB when it comes to query responsiveness? For example, a query that takes two or three seconds to display in OLEDB shows instantaneously in Studio. I even had one query that took 10 seconds in Studio but a minute in OLEDB. This is especially true for queries that involve sorting or distinct. Are there any settings (such as OLEDB properties) I might be missing that would influence this, or is SQL Server Compact Edition fundamentally slower in OLEDB for C++? I'm using a Forward Only cursor which should be the faster one for queries according to the docs.

So apparently the problem is being caused by the parameterized queries I am using... Why would a parameterized query work but take significantly longer for ICommand->Execute to return? Is there some data conversion going on somewhere? I haven't yet tried calling the OLEDB interfaces directly, but it seems to happen with the ATL template classes at least.

No comments:

Post a Comment