Re:Data denormalization is broken
by icebraining on Saturday October 01, 2016 @04:49AM
(#12617082)
I know it uses lazy results, but can you actually loop over the results without triggering a query? Could you write something like:
and only trigger a single UPDATE query?
[ Parent
| on HN ]
There is an update method that can be used with F expressions to achieve this.
This is the example in their docs:
Entry.objects.all().update(n_pingbacks=F('n_pingbacks') + 1)
Re:Data denormalization is broken
by combatentropy on Saturday October 01, 2016 @01:04PM
(#12618750)
To write it in pure SQL would ensure the single query you're looking for and be less to type:
update records
set a = b + 30
where type = 'X'