SQL v.s. Domain Logic 摘要

Resource

  • https://martinfowler.com/articles/dblogic.html

Digest

Where to implement logic :

  • SQL - Database Side
  • Code - In-Memory
    • Transaction Script (Function alike)
    • Domain Object

Comparasion

Performance

  • Most of the time you should focus on writing maintainable code, then use a profiler to identify hot spots and then replace only those hot spots with faster but less clear code.
  • The main reason is in most systems only a very small proportion of the code is actually performance critical, and it's much easier to improve the performance of well factored maintainable code.
  • The complex SQL does the selection and summing of costs in the database and only has to schlep a handful of values back to the client, while the in-memory approach needs to schlep five thousand rows of data back to the client.
Tuning
  • [In-Memory Tuning] Firstly it's worth remembering that in-memory code can often by boosted by more intelligent queries. It's always worth looking to see if you are calling the database multiple times, and if there's a way to do it with a single call instead.
  • [Database Side] You may find that locking issues outweigh anything you can get by faster individual queries.
  • Doing things in-memory as a default, and using things like complex queries for hot spots only when they have to.

Modifiablity

Understandability

Duplication

Encapsulation

Testability

Portability

转载于:https://my.oschina.net/u/3551123/blog/995825

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值