开发者

Disable a list of users in Database

开发者 https://www.devze.com 2023-01-20 06:51 出处:网络
I have a simple question regarding best practices in programming. I have a DB which contain members. After some processing I get a list of users who need to be disabled in DB.

I have a simple question regarding best practices in programming.

I have a DB which contain members. After some processing I get a list of users who need to be disabled in DB.

I have a stored procedure which takes UserId as Input and disable the user.

Since I am sure that I always have to disable more than one user, I am thinking to make input parameter for stored procedure as a Array of Ids rather than Id.

开发者_运维知识库

By doing this I thought I don't have to invoke the SP n times.

Is this a good programming practice?


That question is a little subjective, however less trips to the database is always better. If you can minimize that, I would say go for it.

I have written several complex SProcs in the past that function in the same way. In the end one of the main reasons we write SProcs is for performance tuning. If this is one of the ways to do it, then so be it.


Yes. This will reduce the number of trips the code needs to make to the database which will result in less overhead to the application in question. I'm personally not a big fan of stored procs, but this is an ideal usage for them.

0

精彩评论

暂无评论...
验证码 换一张
取 消