Skip to main content
added 223 characters in body
Source Link
Ashwin
  • 272
  • 2
  • 8
  • 18

I have an inventory table which contains item_id and the quantity remaining of the item (And also some other meta data). I have an administrator update the inventory by uploading a CSV file which contains the item_id and the quantity remaining.

  1. Run `update for each row in the CSV file. If my CSV file contains 1 million rows, I will end up sending 1 million update statements from my application server to the database server.
  2. Construct 1 million update queries and send them in a batch (JDBC allows batched statements)

Is running an `update for each row in the CSV file my only option? If my CSV file contains 1 million rows, I will end up sendingAt first glance approach number 2 looks like a better solution. But then can 1 million update statements from my application server tobe batched? What happens if one of the database server. Is this a good approachstatement fails for some reason?

I have an inventory table which contains item_id and the quantity remaining of the item (And also some other meta data). I have an administrator update the inventory by uploading a CSV file which contains the item_id and the quantity remaining.

Is running an `update for each row in the CSV file my only option? If my CSV file contains 1 million rows, I will end up sending 1 million update statements from my application server to the database server. Is this a good approach?

I have an inventory table which contains item_id and the quantity remaining of the item (And also some other meta data). I have an administrator update the inventory by uploading a CSV file which contains the item_id and the quantity remaining.

  1. Run `update for each row in the CSV file. If my CSV file contains 1 million rows, I will end up sending 1 million update statements from my application server to the database server.
  2. Construct 1 million update queries and send them in a batch (JDBC allows batched statements)

At first glance approach number 2 looks like a better solution. But then can 1 million statements be batched? What happens if one of the statement fails for some reason?

Source Link
Ashwin
  • 272
  • 2
  • 8
  • 18

What is a good strategy for updating lot of rows in postgersql?

I have an inventory table which contains item_id and the quantity remaining of the item (And also some other meta data). I have an administrator update the inventory by uploading a CSV file which contains the item_id and the quantity remaining.

Is running an `update for each row in the CSV file my only option? If my CSV file contains 1 million rows, I will end up sending 1 million update statements from my application server to the database server. Is this a good approach?