Is it possible to display records from ADOQuery during its opening?

I have an ADOQuery related to a DBGrid using a DataSource.
ADOQuery and DataSource are in the DataModule, and the connection is in a different form.

Is there a way to make my applications display strings while the query retrieves records?
Like MSSQL Management Studio.

It takes about 7 minutes to complete the execution.

I am using Delphi 2007.

+6
source share
1 answer

Difficult task. If I need to do massive queries, I usually break the request into pieces. Then I create a stored procedure that takes the @ChunkNumber, @ChunkSize and @TotalChunks parameters. This way you only run a query for records from (@ ChunkNumber-1) @ChunkSize + 1 to @ChunkNumber @ChunkSize. In Delphi code, just run a loop like this (PSeudo code):

for(Chunk = 1 to TotalChunks) { DataTableResults = sp_SomePrecedure @ChunkNumber = @Chunk, @ChunkSize = ChunkSize RenderTableToClient(DataTableResults) } 

So, let's say you have 10,000 records, the block size is 100. Thus, you will have 100 SP calls. Thus, you can display each piece received from the SP so that the user can see the table update.

Limitations - this is that when you start a query, you must first run all the records in one click. For instance. Group. The SQL server uses OFFSET, so you can combine to get something useful.

I have queries that run about 800 thousand records for about 10 minutes to run, with which I do this. But what I am doing is splitting the source tables and then running queries, for example. if one table has 1M records and you want to return a query that shows the total number of pages accessed per hour, you can crop users and run the query for each fragment only.

Sorry, I don’t have specific code examples, but I hope that this suggestion will lead you in a positive direction.

0
source

All Articles