sql - When is using transaction necessary in a web app? -


i wondering, if web request handler needs perform multiple update queries needs atomic group, in django app:

modela.fieldx = true modela.save()   # produce update query on modela table modelb.fieldy = modelb.fieldy + 1 modelb.save()   # produce update query on modelb table 

and there no logical branch taken or exceptions thrown between queries, still need wrap queries in transaction?

and downside of wrapping them in transaction? how affect performance of other queries on relevant tables?

edit: currently, use transactions money-related queries, safe.

usually, transactions necessary data consistency. example, when transfer money account account b should update amounts in accounts , b in transaction avoid situations when decrease amount of account amount of account b not increased due exception or other reason.

long transactions bad relational databases because increases locking of db resources , increases overhead costs it

i suggest using short transactions possible sure consistency of data.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -