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

Speed up suggestion insertion by using a single transaction #11702

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ public static void insertSuggestionsForSite(final long siteId, final List<Sugges
// we want to delete the current suggestions, so that removed users will not show up as a suggestion
deleteSuggestionsForSite(siteId);

// Including the insertion of all suggestions in a single transaction dramatically improves insertion
// performance when there are a lot of suggestions
getWritableDb().beginTransaction();
if (suggestions != null) {
for (Suggestion suggestion : suggestions) {
addSuggestion(suggestion);
}
}
getWritableDb().setTransactionSuccessful();
getWritableDb().endTransaction();
}

public static void addSuggestion(final Suggestion suggestion) {
Expand Down