I have a table like the one below in SQL Server:
I have an API that receives 15,000 records every 10 seconds to save in the table above. As if userid
exist update that row if not exist userid insert record. I use the following code to write the record of each user with pyodbc (in python) That means I run the following code 15,000 times :
update Mytable
set buy = ?, model = ?, price = ?, color = ?, number = ?,
balance = ?, time = ?, type = ?,
where userid = ?
if @@ROWCOUNT = 0
insert into Mytable (userid, buy, model, price, color,
number, balance, time, type)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
The above code works fine but takes 700 seconds for 15,000 records. I have just this API and I have no other information about the number of users and ...
How can I save 15,000 records in less than seven seconds?