When should I use stored procedures?

前端 未结 19 2521
眼角桃花
眼角桃花 2020-12-04 10:53

When should I be using stored procedures instead of just writing the logic directly in my application? I\'d like to reap the benefits of stored procedures, but I\'d also lik

19条回答
  •  死守一世寂寞
    2020-12-04 11:37

    The stored procedures are a method of collecting operations that should be done together on database side, while still keeping them on database side.

    This includes:

    • Populating several tables from one rowsource
    • Checking several tables against different business rules
    • Performing operations that cannot be efficiently performed using set-based approach

    etc.

    The main problem with stored procedures is that they are hard to maintain.

    You, therefore, should make stored procedures as easy to maintain as all your other code.

    I have an article on this in my blog:

    • Schema junk

提交回复
热议问题