I am getting Out of memory exception while retrieving all the issues of a project area. It has around 600K Jira issues. Here is my code
final SearchProvider searchProvider = ComponentAccessor.getComponent(SearchProvider.class);
try {
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
Query query = queryBuilder.where().project(projectId).and().updated().gt(dayAfter.getMillis()).buildQuery();
SearchResults searchResults = searchProvider.search(query, appUser, PagerFilter.getUnlimitedFilter());
return getIssuesFromResult(searchResults);
}
catch (SearchException e) {
logger.error(e.getMessage());
}
Can we do it more efficient way like using paging
Here is the OOM getting thrown, in the SearchResults searchResults = ... ? or in the following line?
Do you need all the information SearchResults provides or are you looking for specific information? If so, perhaps you should considering creating a return type that will provide only the necessary information.
Alternatively, you could https://developer.atlassian.com/server/confluence/atlassian-cache-2-overview/ the SearchResults and paginate over those.
Hope the above helps, if not, please let us know what you are trying to accomplish with the method described and we may find a solution together.
Kind regards,
Rafael
I am able to get rid of this by using paging like this
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
queryBuilder.where().project(project.getId()).and().updated().gt(dayAfter.getMillis());
queryBuilder.orderBy().issueId(SortOrder.ASC);
com.atlassian.query.Query query = queryBuilder.buildQuery();
int startIndex = 0;
int limit = 50;
while(true){
PagerFilter filter = new PagerFilter(startIndex, limit);
SearchResults searchResults = searchProvider.search(query, appUser, filter);
List<Issue> issues = JiraManager.getIssuesFromResult(searchResults);
if(issues != null && issues.size() > 0){
// Do Something
}
startIndex += limit;
}else{
break;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.