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

removed extra save method leading more writes on database #167

Closed
wants to merge 1 commit into from

Conversation

SitaGanesh
Copy link

@SitaGanesh SitaGanesh commented Dec 9, 2024

Checklist

  • I have read the [OpenWISP Contributing Guidelines]

(http://openwisp.io/docs/developer/contributing.html).

  • I have manually tested the changes proposed in this pull request.

  • I have written new test cases for new code and/or updated existing tests for changes to existing code.

  • I have updated the documentation.

Reference to Existing Issue

Closes #120.

Description of Changes

This pull request improves the efficiency of the save() method in the model. Combining multiple database operations into a single one reduces the number of database calls and improves performance.

Screenshot

git4

git3

git

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SitaGanesh, we need to add an assertion in the tests that checks the number of queries, comparing beforing and after this patch, there should be at least 1 less query.

The test method is called assertNumQueries.

Can you add this please?

@SitaGanesh
Copy link
Author

Yes, Thankyou Sir @nemesifier I have some idea about this, but could you clarify me sir, which specific part of the code base this fix applies to? Is it related to the save method which was optimized, or does it target a different area? This will help me know the request to be changed.

@SitaGanesh
Copy link
Author

Sir @nemesifier, I have created a PR for tests that checks the number of queries, comparing beforing and after this patch. Refer to this #168 (2d36e61

@nemesifier nemesifier closed this Dec 23, 2024
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.

[bug] CA/Cert creation generates 2 SQL write queries instead of 1
2 participants