Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize how updates are done in _save() method #198

Conversation

birinsanchez
Copy link

django-ldapdb library always issues an ldap.MOD_REPLACE request to the LDAP server when saving an updated LDAP entry. This can cause big delays in some cases.

Imagine you have a model representing a LDAP group with a field of type ListField. That field is used to store the group members. If your group has thousands of members, when you add/remove a member django-ldapdb sends the whole list of members (thousands) to the LDAP server.

This PR sends ldap.MOD_REPLACE, ldap.MOD_DELETE or ldap.MOD_ADD depending on
how the value changes instead of always sending ldap.MOD_REPLACE.

how the value changes instead of always sending ldap.MOD_REPLACE.

Signed-off-by: Birin Sanchez <birin.sanchez@puri.sm>
@Natureshadow
Copy link
Member

The logic is incomplete and wrong. The length has no meaning — jsut because the new attribute list has less entries does not imply that only entries were removed. Maybe 2 were removed and one new added, or even all removed and less new ones added?

You would have to compare the lists entry for entry. I do not think it's worth the effort, so closing. If you have a different opinion, please provide profiling that proves that the replace operation costs measurably more than tracing the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants