I am using ASP.NET and SQL Server. I would like to load data from database asynchronously and show data which are partially loaded immediately.
Suppose there are tons of records in a query result. After 3 sec,It loads 20% then I have to process and show 20% data immediately, not waiting for complete response. I know $.Ajax in jQuery to load data async. Is it possible to process partial response, Not wait for complete response and show it immediately.
Is there any way to get this?
Suppose there are tons of records in a query result
You have to aks yourself: Will the end user see a ton of records at once?
You don't specify what and how you are showing the data, so I'm going to assume that you are showing the data in something like a Grid.
What we do this days on such commun scenario is to load data using pages and fire it when the user scrolls the grid down, you can even see this in mobile devices and even on facebook, Twitter, etc...
It will load the first page (for example we set up the page to be 20 records), so it will load the first 20 records (page 0), but soon you reach the bottom, it will automatically load 20 more records (page 1).
This technique is called Infinite Scroll
Like Alex said you can't start showing a partial response... I bet your wait time is related to the time it takes to query and return the dataset, not the time it takes to render the date. That being said you could easily create the functionality to only get the first 20% of the records before trying to get the last 80%. Of course you would load each result asynchronously.
The downside to this is that you have to generate 2 requests/response cycles and 2 database queries.
Just curious how long does it take to run the SQL query outside of your website (using SQL Manager for example)? How much data is actually being returned 10kb or 1000kb? If you have a lot of text data, look at adding compression, to your responses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With