| ▲ | JodieBenitez a day ago | |||||||||||||||||||||||||||||||
> BEGS you to cause n+1 problems select_related, prefetch_related. n+1 problems be gone. | ||||||||||||||||||||||||||||||||
| ▲ | DarkNova6 a day ago | parent | next [-] | |||||||||||||||||||||||||||||||
You misunderstand. And that is exactly the problem. We did do that and that's why our queries ended up being several lines long. But if you missed just one model? You openly walk a knife again. It's a mess and it only gets longer and longer. I ended the project with having some proper aggregates, only for that to be thrown out of the window by the guy after me. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ▲ | ranger_danger a day ago | parent | prev [-] | |||||||||||||||||||||||||||||||
It still selects all fields by default. Very often I have to use defer() or only() to get rid of expensive columns like blob/text that are rarely used and greatly hurt performance when grabbing them. Then it got to where I had to make a reflective function that I use like Model.objects.defer(*all_fields_except(Model, ['field1', 'field2'])), and then add another all_fields_except() for every select_related and prefetch_related. Even save() by default re-writes every single field. You have to use save(update_fields=['field1']) instead. | ||||||||||||||||||||||||||||||||