You almost never want to use Read Uncommited
since it's not really ACID
compliant. Read Commmited
is a good default starting place. Repeatable Read
is probably only needed in reporting, rollup or aggregation scenarios. Note that many DBs, postgres included don't actually support Repeatable Read, you have to use Serializable
instead. Serializable
is useful for things that you know have to happen completely independently of anything else; think of it like synchronized
in Java. Serializable goes hand in hand with REQUIRES_NEW
propagation.
I use REQUIRES
for all functions that run UPDATE or DELETE queries as well as "service" level functions. For DAO level functions that only run SELECTs, I use SUPPORTS
which will participate in a TX if one is already started (i.e. being called from a service function).