Understanding Jira Indexing and JQL
Automatic vs. Manual Indexing
Jira relies on indexing to deliver fast and reliable searches:
- Automatic Indexing: Occurs when an issue is created, updated, deleted, or transitioned mostly.
- Manual Indexing: Triggered by administrators to rebuild index when needed.
Leveraging JQL
Jira Query Language (JQL) allows users to search issues with precision. For example:
|
|
This retrieves all issues in the "CUSTOM" project, ordered by creation date.
Accessing Data Using JQL
Via Jira Issue Search (UI)
The web UI provides a visual way to execute JQL and view results:
<JIRA_BASE_URL>/browse/CUSTOM-1?jql=project%20%3D%20CUSTOM%20ORDER%20BY%20created%20DESC |
Via Jira REST API
Integrate Jira with external systems using REST API queries:
<JIRA_BASE_URL>/rest/api/2/search?jql=project%20%3D%20CUSTOM%20ORDER%20BY%20created%20DESC |
Via Jira Issues Macro in Confluence
Display Jira data in Confluence using macros:
<JIRA_BASE_URL>/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project%20%3D%20CUSTOM%20ORDER%20BY%20created%20DESC |
ScriptRunner for Jira DataCenter: Script Fields
Script Fields in ScriptRunner allow Groovy-based customizations to enhance issue data. For instance:
// enable/disable cacheenableCache = {-> true}// sleep for 10 secondssleep(10000)// create instance of Random classRandom random = new Random();// Generate random integers in range 0 to 999int randomValue = random.nextInt(1000);log.warn("Issue: ${issue.getKey()}, Random value: ${randomValue}")// return value to be defined in Script Fieldreturn String.valueOf(randomValue) |
Benchmark Results
With Cache Enabled
- The script executes once, updating the field after 10 seconds.
With Cache Disabled
- The script executes multiple times, significantly delaying responses
| Scenario | Cache | Execution | Comment |
|---|---|---|---|
| Jira Issue Search (UI) |
Enabled | 1x | Issue gets rendered and after 10 seconds the script fieldRandom number gets updated with a new random value. |
| Disabled | 7x | Since there is a sleep of 10s, Jira UI will await for over 60 seconds before failing on rendering the result of the JQL query. |
|
| Jira REST API | Enabled | 1x | JSON response is given after 10 seconds |
| Disabled | |||
| Jira Issue Macro | Enabled | 1x | XML response is given after 10 seconds |
| Disabled | 3x | XML response is given after 30 seconds |
Additional Insight: Execution Metrics in ScriptRunner
ScriptRunner provides execution statistics that are invaluable for debugging and performance assessment. As noted in its documentation on Script Fields, the execution count is recorded regardless of the cache setting. This highlights:
- Even with caching, the field’s script executes once per relevant rendering or search operation.
- When caching is disabled, these metrics can reveal a dramatic increase in execution frequency, correlating directly to system delays.
This underscores the importance of monitoring execution counts and understanding how cache settings affect the behaviour of Script Fields, especially in large-scale Jira instances.
The Performance Challenge
Search for Script Field Value(s)
The Random number field demonstrates the issue:
- Cached: Executes once.
- Uncached: Executes multiple times, causing delays.
Performance Implications
Requests to retrieve Script Field values scale with issue volume:
- 1 issue = 10 seconds
- 100 issues = 1000 seconds. This creates significant bottlenecks for large datasets.
Strategies to Prevent Performance Bottlenecks
Optimize Data Retrieval
- UI: Use the List view and display only required fields.
- REST API: Specify only necessary fields in API requests.
- Confluence: Narrow displayed columns in Jira Issues Macro.
Use Pre-Computed Fields with Cron Jobs
Instead of live computation:
- Create a Custom Field for pre-computed data - not a Script Field
Random number - cron job, custom field to receive the random value generatedRandom number - last updated, custom field to receive a timestamp from when custom field was last updated
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.user.ApplicationUserApplicationUser applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()final String jql = 'project = PROJ ORDER BY created DESC'long issueCount = Issues.count(jql)log.info("${issueCount} issues were found with jql=\"${jql}\"")List<Issue> issues = Issues.search(jql).toList()issues.each { issue -> // create instance of Random class Random random = new Random(); // Generate random integers in range 0 to 999 int randomValue = random.nextInt(1000); log.info("Random value ${randomValue} generated") Issues .getByKey(issue.getKey()) .update { log.info("Update issue \"${issue.getKey()}\"") setCustomFieldValue('Random number - cron job', String.valueOf(randomValue)) setCustomFieldValue('Random number - last updated', new Date().format("yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("UTC"))) }} |
Conclusion
Customizing Jira with ScriptRunner's Script Fields can deliver powerful features, but improper configuration leads to performance degradation. By optimizing searches, limiting unnecessary field executions, and precomputing field values with cron jobs, you can harness the full potential of Jira DataCenter while maintaining performance.
This blog post provides a practical guide for administrators and developers to ensure Jira remains performant while utilising the extensive capabilities of ScriptRunner for Jira DataCenter.
Ready to Optimize Your Jira Experience?
Are you facing performance challenges with ScriptRunner in your Jira DataCenter environment? Or perhaps you're planning a migration to Atlassian Jira Cloud?
Our team of experts can help you:
- Review your current ScriptRunner setup to identify performance bottlenecks
- Recommend optimizations for your Script Fields and custom scripts
- Create a seamless migration strategy from Jira DataCenter to Cloud
- Adapt your existing scripts to work efficiently in ScriptRunner for Jira Cloud
- Ensure your customizations continue to deliver value without compromising performance
Don't let performance issues or migration concerns hold you back. Whether you're looking to improve your current DataCenter implementation or make the move to Cloud, our consultants bring years of experience in Atlassian ecosystems and ScriptRunner customizations.
Get in Touch
Contact us today for a no-obligation consultation. We'll help you harness the full potential of ScriptRunner while maintaining optimal performance — wherever you choose to run Jira.
Contact Our Atlassian Experts →
Acknowledging the Author and Team Behind the Insights
![]()
|
This blog post, Enhancing Performance of ScriptRunner for Jira Data Center - Script Fields in Atlassian Jira, has been authored by Rafael Pinto Sperafico, an experienced professional specializing in Atlassian tools. With a robust background in project management, agile methodologies, and a focus on performance optimization in Jira environments, Rafael brings invaluable expertise to this topic. You can explore more about his professional journey on LinkedIn. Furthermore, this content reflects the collective insights of Ambientia's Atlassian Team, a group renowned for its technical acumen, long-term client relationships, and exceptional team spirit. Ambientia has been at the forefront of leveraging Atlassian products to drive meaningful business transformations. To dive deeper into their approach and success stories, visit Ambientia’s feature on their Atlassian Team. Here, you’ll learn how they blend technical expertise with collaboration to provide outstanding solutions. Even if you don’t speak Finnish, the page showcases their commitment to excellence and innovation in the Atlassian ecosystem. |
Subscribe to our content
Do you want our content in your email? Among other things, we offer information on service management and customer experience development
More related
Atlassian
Part 1: ScriptRunner Console Monitoring: The Hidden Security Gap in Your Jira Environment
Unmonitored ScriptRunner use in Jira can expose hidden security risks and threaten your ISO 27001 compliance.
Read more
Published 19.6.2025 | Updated 19.6.2025
Atlassian
Securing Multi-Contractor Jira DataCenter Environments: Why ScriptRunner SDK is Your Compliance Game-Changer
ScriptRunner SDK transforms Jira security with audit logs, controlled access, and compliance for multi-contractor environments.
Read more
Published 14.8.2025 | Updated 14.8.2025

.png?width=225&height=300&name=IMG_7964%20(1).png)