tags:

views:

47

answers:

1

We are building an application which requires a daily insertion of approximately 1.5 million rows of data per table. We have 16 tables. We keep track of 3-day historical data including the current day's data.

The application is done using C#; on the server side, we run an exe that fills the data tables during market hours (4.5 hours), and we update the 16 tables every 5 seconds.

On the client side, the application gets user queries which require the most recently inserted data ( in the last 5 seconds) and a historical point which could be today or before, and plots them somehow.

We are having some serious performance issue, as one query might take 1 second or more which is too much. The question is, for today's data that is being inserted at runtime, can we make use of caching instead of going to the database each time we want something from today's data? Will that be more efficient? And if so, how can we do that? P.S one day data is approximately 300 MB, and we have enough RAM

A: 

Keep a copy of the data along with the datetime you used to retrieve the data. The next time, retrieve only the new data, which minimizes the amount of data you send over the wire.

If it is that all the queries run in the operation amount to 1 sec, maybe the issue you are seeing is that the UI is freezing. If that is the case, don't do it on the UI thread.

Upate (based on comments): the code you run in the event handlers of the controls, runs in the UI thread, which is what causes the UI to freeze. There isn't a single way to run it in a separate thread, I suggest BackGroundWorker for this scenario. Look the community provided example at the end.

eglasius
thanks for answering .. The query time is 0 second now after some optimization. However, we are querying over a 512 VPN connection and the UI is freezing. I didn't get what you really proposed to solve that! Could you elaborate a bit more?
Mustafa A. Jabbar
@mustafabar added an update about it.
eglasius