Click here to Skip to main content
15,886,011 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello,

I want to fetch large amount of data from mssql database by using node js. I have tried by calling stored procedure but, taking so much time for loading all the records. When I execute the Query in SSMS then it take hardly two seconds for loading.
Can anybody suggest how to reduce the time for fetching

What I have tried:

I have tried by calling stored procedure but, taking so much time for loading all the records. When I execute the Query in SSMS then it take hardly two seconds for loading.
Can anybody suggest how to reduce the time for fetching
Posted
Updated 19-Apr-21 1:40am
Comments
Richard Deeming 19-Apr-21 7:27am    
There's obviously a secret error somewhere in your secret code. You should fix that.

NB: Loading 200,000 records into memory to either process or display to the user is almost certainly the wrong thing to do. For processing, it would be better to do the work in the database itself. For displaying to the user, you'll need to use searching and paging, or find some other way to let the user find the record(s) they're looking for.

Basically, don't.
All javascript code runs on the client, so you have to query the DB server, transfer the data across the internet to your browser, and then (I assume) render it to the user.

And the most significant time portion of that is taken by displaying to the user.

Which is silly - no user wants 100,000 rows or more dumped in front of him, regardless of how long it takes to display it. Because that time - however long it is - ir trivial compared to his time spent trying to find the one row he is actually interested in.

Never show a user more than a couple of hundred rows at most: page it, filter it, search it, sort it - but just selecting it and dumping it in front of him is going to mean the user leaves your site pretty quickly, and doesn't come back. Ever.
 
Share this answer
 
Comments
Richard Deeming 19-Apr-21 8:29am    
Node.js runs on the server. :)
About | Node.js[^]
Quote:
Can anybody suggest how to reduce the time for fetching

Solutions are:
- Get faster server, faster storage.
- Optimize database (database design), indexes
- Get faster network
- Reduce size of data to load on page.

Without indication of what is this database, optimization is on your own, DataBase Design is a job on its own.

Loading 200000 records on a web page is a bad idea in 99.99% of time.
There is no magic to speedup the queries.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900