My idea is that for every TMSQuery that can potentially return many records I use a cache mechanism.
I found a way to savetofile MSQuery1 using TVirtualTable and TCRBatchMove in this way:
Code: Select all
CRBatchMove1.Source := MSQuery1; CRBatchMove1.Destination := VirtualTable1; // I need to Copy FieldDefs VirtualTable1.FieldDefs := MSQuery1.FieldDefs; CRBatchMove1.Execute; VirtualTable1.SaveToFile('Test.dat');
This works but it is very slow, I tried with 1000 records and it is much slower than retrieving data from a DB in LAN.
So QUESTION1: is this the best that can be done or is there a more efficient way to cache data locally?
Moreover To use RefreshQuick TimeStamp somehow is used, so I should SaveToFile also the TimeStamp info to allow to use RefreshQuick without calling Open.
TO summarize what I want to achieve is this (is it possible?):
1) RUN the application
2) as a TMSQuery needs to be opened I check if it has been cached (so if a file has been saved):
2a) if yes I load the data to the TMSQuery including timestamp info and then I call RefrshQuick
2b) if not I simply call TMSQuery.Open
Of course there are many issues, but those are not related to this question (like: MSQuery can have different Params, one MSQuery can have different SQL code accodrding to application logic, there can be security issues by caching critical data, ...).
NOTE: THe need of caching comes for the scenarios in which the connection to the server is very slow (users accessing with VPN from remote connection for example).