Fix error when creating node queries for large datasets#631
Merged
javuto merged 1 commit intojmpsec:mainfrom Mar 28, 2025
Merged
Fix error when creating node queries for large datasets#631javuto merged 1 commit intojmpsec:mainfrom
javuto merged 1 commit intojmpsec:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses an error encountered when creating node queries for large datasets by applying batch creation to prevent performance issues.
- Replaces q.DB.Create with q.DB.CreateInBatches using a hard-coded batch size (1000).
- Aims to improve performance for datasets with more than 10,000 nodes.
Comments suppressed due to low confidence (1)
pkg/queries/queries.go:411
- [nitpick] Consider using a global configuration variable for the batch size instead of hardcoding 1000, in order to align with the intended DB configuration.
if err := q.DB.CreateInBatches(&nodeQueries, 1000).Error; err != nil {
Collaborator
|
Is there something missing in this PR? |
javuto
approved these changes
Mar 27, 2025
Collaborator
|
Nevermind, I found the documentation https://gorm.io/docs/create.html#Batch-Insert |
Collaborator
|
If we apply the configuration using the |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Implement batch creation of node queries to handle more than 10,000 nodes efficiently.
It's a quick fix and I think it's a good idea to applied the batchsize as a global configuration for DB cofig.
It can be done by: