In one project, I've noticed that we do quite a lot of validations, to the point where a simple PUT incurs about 40 queries. I've managed to bring it down to about two thirds of that by overriding binder_full_clean to do nothing.
As far as I know, we're using django-full-clean in all our projects, so that whenever you call save(), full_clean gets triggered anyway. Maybe it's time to make it official and require it in Binder. Then we can drop most of binder_full_clean.
I've also noticed that full_clean doesn't support selectively disabling constraint validations. I think that if we see that a model includes the LoadedValuesMixin, we can check if any relations have changed. If not, we can in principle assume that all the foreign key constraint validations will succeed and pass all unchanged relations as exclude. If none of the uniqueness fields have changed, we can also pass in validate_unique=False. Now, there can be race conditions, but I think because we're using select_for_update that isn't or can't really be the case.
If we want to leverage LoadedValuesMixin, I think we must build our own django_full_clean replacement as part of Binder. This is not a big deal, as the implementation is just a handful of lines anyway.
In one project, I've noticed that we do quite a lot of validations, to the point where a simple PUT incurs about 40 queries. I've managed to bring it down to about two thirds of that by overriding
binder_full_cleanto do nothing.As far as I know, we're using django-full-clean in all our projects, so that whenever you call
save(),full_cleangets triggered anyway. Maybe it's time to make it official and require it in Binder. Then we can drop most ofbinder_full_clean.I've also noticed that
full_cleandoesn't support selectively disabling constraint validations. I think that if we see that a model includes theLoadedValuesMixin, we can check if any relations have changed. If not, we can in principle assume that all the foreign key constraint validations will succeed and pass all unchanged relations asexclude. If none of the uniqueness fields have changed, we can also pass invalidate_unique=False. Now, there can be race conditions, but I think because we're usingselect_for_updatethat isn't or can't really be the case.If we want to leverage
LoadedValuesMixin, I think we must build our owndjango_full_cleanreplacement as part of Binder. This is not a big deal, as the implementation is just a handful of lines anyway.