How to optimize the usage of TMSQuery on remote connection?
Posted: Wed 09 Sep 2009 14:12
Hello,
I am hitting a performance wall when using my client/server application with a remote connection. Typical scenario is User has Client EXE on Laptop, he uses a mobile connection and with VPN he connects to company LAN to access SQLServer and document folders.
(same scenario with VPN and with direct connection to SQL server through external IP can occur, nothing changes for my example)
The problem is that every time I run a query, there is a latency. The latency depends on connection speed. But to give you an idea with a normal internet connection I expereince something like 200ms of latency, while with slower connection the latency is more than 1000ms.
For latency I mean that even if the query returns a single value (for example in the simple query
SELECT CUSTOMER_NAME
FROM CUSTOMERS_TABLE
WHERE CUSTOMER_ID = 10
)
takes a lot of time to execute, 200ms.
A query that returns a lot of more data, like the following 100 records query:
SELECT CUSTOMER_ID, CUSTOMER_NAME, CUSTOMER_ADDRESS, CUSTOMER_PHONE, CUSTOMER_LONG_DESCRIPTION
FROM CUSTOMERS_TABLE
WHERE CUSTOMER_ID <=100
takes 240ms. So the big amount of data returned (more than 1000 more data) has a minimal difference in time.
So this is why I speak about latency.
Anyway it seems this is SQL Server behaviour, I would like to understand why there is all this latency. I tried with Management Studio and query execution time are the same (I mean I tried with management studio from remote connection).
So the point is, my application, super simplified, is like this:
1) after login There is a TMSConnection.Connect to the DB
2) during the software execution I have many time data blocks kile this:
procedure DummyProcedure;
begin
MSQuery1.Open;
MSQuery2.Open;
MSQuery3.Open;
MSQuery4.Open;
MSQuery5.Open;
MSQuery6.Open;
MSQuery7.Open;
end;
MSQuery1 to 7 basically return few data tipically, but since every MSQuery has the latency, if latency is 200 ms the above DummyProcedure will take 200*7 =1,4 seconds to execute, while in LAN it is instantanious...
Can you comment on this?
Is there a way to avoid that latency I am speaking about?
I run queries also for setting some popupmenuitem's visibility, so even the display time of some popupmenus is sometimes not acceptable.
Thanks.
I am hitting a performance wall when using my client/server application with a remote connection. Typical scenario is User has Client EXE on Laptop, he uses a mobile connection and with VPN he connects to company LAN to access SQLServer and document folders.
(same scenario with VPN and with direct connection to SQL server through external IP can occur, nothing changes for my example)
The problem is that every time I run a query, there is a latency. The latency depends on connection speed. But to give you an idea with a normal internet connection I expereince something like 200ms of latency, while with slower connection the latency is more than 1000ms.
For latency I mean that even if the query returns a single value (for example in the simple query
SELECT CUSTOMER_NAME
FROM CUSTOMERS_TABLE
WHERE CUSTOMER_ID = 10
)
takes a lot of time to execute, 200ms.
A query that returns a lot of more data, like the following 100 records query:
SELECT CUSTOMER_ID, CUSTOMER_NAME, CUSTOMER_ADDRESS, CUSTOMER_PHONE, CUSTOMER_LONG_DESCRIPTION
FROM CUSTOMERS_TABLE
WHERE CUSTOMER_ID <=100
takes 240ms. So the big amount of data returned (more than 1000 more data) has a minimal difference in time.
So this is why I speak about latency.
Anyway it seems this is SQL Server behaviour, I would like to understand why there is all this latency. I tried with Management Studio and query execution time are the same (I mean I tried with management studio from remote connection).
So the point is, my application, super simplified, is like this:
1) after login There is a TMSConnection.Connect to the DB
2) during the software execution I have many time data blocks kile this:
procedure DummyProcedure;
begin
MSQuery1.Open;
MSQuery2.Open;
MSQuery3.Open;
MSQuery4.Open;
MSQuery5.Open;
MSQuery6.Open;
MSQuery7.Open;
end;
MSQuery1 to 7 basically return few data tipically, but since every MSQuery has the latency, if latency is 200 ms the above DummyProcedure will take 200*7 =1,4 seconds to execute, while in LAN it is instantanious...
Can you comment on this?
Is there a way to avoid that latency I am speaking about?
I run queries also for setting some popupmenuitem's visibility, so even the display time of some popupmenus is sometimes not acceptable.
Thanks.