prDirect Connect heavily slower then prAuto

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
itsds
Posts: 37
Joined: Mon 30 Apr 2007 10:38
Location: Germany - Bochum
Contact:

prDirect Connect heavily slower then prAuto

Post by itsds » Fri 29 Nov 2019 09:37

Hi i use UniDAC 8.1.2 for SQL Server 11 with mORMot's SynDBUniDAC.
Here i made some Speedtests and compared the divers SQL Server.Provider Options.
The Queries itself are nearly with the same Speed. But in the first Connect Part of any ServerRequest the prDirect Option uses 120ms on my System to Connect. the prAuto only 10ms that is 12times slower.

We use mORMot as Rest/Soa Service, for every Rest Request the Connection is newly opened.
Some Heavily transfers use 2seconds with prAuto and 10s with prDirect.
The Reason ist the 120ms Connection Time.

Does anybody have a idea why direct connect is that slower ?

ertank
Posts: 172
Joined: Wed 13 Jan 2016 16:00

Re: prDirect Connect heavily slower then prAuto

Post by ertank » Fri 29 Nov 2019 11:23

Hello,

I unfortunately do not have an answer to your question. I just wonder if you can use pooling? That might help you after first requests or even at the beginning.

However, I am interested in your test project. I failed to use UniDAC with mORMot myself in the past. If you can provide a complete example with necessary database backup that I very much appreciate.

Thanks & regards,
Ertan

itsds
Posts: 37
Joined: Mon 30 Apr 2007 10:38
Location: Germany - Bochum
Contact:

Re: prDirect Connect heavily slower then prAuto

Post by itsds » Sat 30 Nov 2019 09:20

Hi thank you for your answer, i found the reason after 1h debugging.
i had to set SQL Server.ConnectionTimeout to 0 (zero) if it is set to a value > zero in TryConnect a WaitForConnect is called where Connector.Wait Function in CRvioTcp.pas is called which waits approx 90ms in WaitForSingleObject.
Set to 0 InternalConnect instead is called which is extremly faster.

Problem solved.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: prDirect Connect heavily slower then prAuto

Post by Stellar » Mon 02 Dec 2019 13:05

UniDAC works with MS SQL Server using TCP/IP protocol in the Direct mode, but when using the Native Client, the default protocol is Shared Memory. You can try setting in the Native Client settings that the use of the TCP/IP protocol is required, and this issue will most likely be relevant for the Native Client.

Glad to see that the issue was resolved.
Feel free to contact us if you have any further questions about our products.

Post Reply