I’m trying to speed up the process of getting the total count of Jira issues for a project using jira-python. Right now my code is fetching all the issues which is pretty slow:
project_issues = jira_client.fetch_issues('project=MyProject and assignee != currentUser()')
I’ve tried setting max_results=0 to just get the count but it returns an empty list:
issue_count = jira_client.fetch_issues('project=MyProject and assignee != currentUser()',
start_at=0,
max_results=0)
Is there a faster way to get just the total count without retrieving all the issue details? I know JQL has a way to do this but I’m not sure how to implement it in jira-python. Any tips would be super helpful!
This approach fetches only one issue but returns the total count in the response object. It’s generally faster than retrieving all issues or using maxResults=0, which can sometimes behave unexpectedly.
Remember to import the required libraries and initialize your JIRA client properly. Also, consider implementing error handling to manage potential API request failures or authentication issues.
This method has worked well for me across various project sizes, offering a good balance of speed and reliability.
I’ve actually encountered this issue before when working on a large-scale project tracking system. The search_issues() method mentioned earlier is definitely a step in the right direction, but I found that combining it with the ‘fields’ parameter can make it even faster. Here’s what worked for me:
By specifying ‘fields=none’, you’re telling Jira to skip fetching any field data, which significantly speeds up the query. This approach gave me near-instantaneous results even on projects with tens of thousands of issues.
Just remember to handle potential exceptions, as network issues or invalid JQL can sometimes cause hiccups. Also, keep in mind that this count includes all issue types, so you might need to adjust your JQL if you’re looking for specific issue types only.