Skip to main content
January 31, 2024
Question

What is the Best way to write high volume of data into database

  • January 31, 2024
  • 3 replies
  • 0 views

Hi All,

I have an interface where we are having paragraph field and grid . User will be giving data in the paragraph field in specific format and will click on add button, Once they clicked on it, it will be written into database and the grid will be refreshed with the added data. There are some use cases where user will be adding more than 2000 records at a time. Currently it is taking around 2 minutes to load the 500 records into database.  What is the best way to save the data into database with minimal time? Could someone please help me on this

3 replies

harshitb6843
January 31, 2024

There could be multiple ways of looking at it based on what is more important. 

  1. If the priority is to take less time, then I will advise changing the approach and letting the user save every record once they are done working on it. This will surely increase the clicks but will ensure that every data is saved instantly so the 2 minutes is reduced to almost negligible. 
  2. If the priority is to keep it performant and keep the user efforts minimal, then I will advice writing the data in batches of 100 and calling this process as an async process. You can add a refresh interval of 30 seconds on your grid data to auto-refresh and show the newly written batch of data
mathieud0001
Brainy
February 1, 2024

Not much you can do to speed up the writes but I am curious to know how many columns these records have.

I can write 1000 records from a JSON in 2-3 seconds.

abhayd3663
February 2, 2024

It is definitely not a best practice to maintain large volume of records in draft/editable mode and save it in single transaction.