如果我在SQL中一个接一个地写入多个表上有多个更新和插入,我该如何优化代码?

时间:2021-02-08 20:56:55

Code structure:

Public void Function() throws ioexcption

Update table a set values
Update table b set values
Insert into c values
Insert into d values
Many more updates and inserts

Function ends

How do I optimise the code? As the current code few minutes to complete when thousands of records are there. Will stored procedures help or will indexing help?

如何优化代码?由于当前代码只需几分钟即可完成,当时有数千条记录。存储过程是帮助还是索引帮助?

1 个解决方案

#1


2  

Write all the changes in a file, read the file, parse every line, create a prepared statement, populate the parameters and execute it.

将所有更改写入文件,读取文件,解析每一行,创建预准备语句,填充参数并执行它。

#1


2  

Write all the changes in a file, read the file, parse every line, create a prepared statement, populate the parameters and execute it.

将所有更改写入文件,读取文件,解析每一行,创建预准备语句,填充参数并执行它。