Is it better to use stored procedures instead of SQL statements in a C application?

I am developing an application that requests data from a host and then inserts it into an SQL database. My application runs randomly on our PC (we have 600-700 PCs) from a place on the server, so my application is not on all PCs. It is located only on the server. Therefore, it is possible that sometimes it runs on 50 PCs.

I keep getting two types of SQL error messages. The first timeout and the other is an SSL security error. Now my application executes about 5-10 SQL commands. So I'm thinking of rewriting my code to call stored procedures that can reduce the number of SQL calls. The question is, is it worth it? I mean, of course, this has its advantages, because if I need to change something, it is enough to change the stored procedure, and I do not need to recompile my application. But won't this cause a problem for the SQL server? I mean this is not a problem when the same stored procedure will be executed 50 times at the same time?

So which way is better? Using stored procedures or using SQL commands in my code?

Thanks!

+4
source share
1 answer

If you often call several identical SQL statements in a row, the answer is clear: use SP to reduce the number of rounds. The load on your SQL server will not change, but network latency will decrease due to the reduction in the number of rounds. As an added bonus, your system architecture can become easier to understand and maintain, as complex SQL logic will be encapsulated at your data access level.

This may not have anything to do with your SSL errors, but the timeout situation has a good chance of improvement.

+4
source

Source: https://habr.com/ru/post/1389504/


All Articles