-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Highest
-
Affects Version/s: 12.1.3
-
Component/s: Database (MySQL)
-
None
-
1
-
Severity 2 - Major
-
1
Issue Summary
Bamboo’s Hibernate generated queries against BUILDRESULTSUMMARY include CAST(BUILD_KEY AS CHAR) in the WHERE clause, which prevents MySQL from using the optimal BUILD_KEY, leading composite index.
As a result, MySQL chooses a much more expensive execution plan (index intersection or wide-range scans), resulting in slower execution and very high DB CPU under load.
The CAST appears to be introduced by code using .as(String.class) on an already string column.
predicates.add(cb.equal(entity.get(PLAN_KEY).as(String.class), planKey));
Steps to Reproduce
N/A
Expected Results
Remove the CAST appending in already string values
Actual Results
Explain Plan with CAST:
Limit: 25 (cost=50843 rows=25) (actual time=3823..3823 rows=12)
-> Sort: BUILD_NUMBER DESC (cost=50843 rows=196252) (actual time=3823..3823 rows=12)
-> Filter: MARKED_FOR_DELETION=0 AND LIFE_CYCLE_STATE='Finished'
AND cast(BUILD_KEY as char)='AHNRT-HNRTADDP'
(cost=50843 rows=196252) (actual time=1998..3823 rows=12)
-> Intersect rows sorted by row ID (actual rows≈631,858/766,999)
Without CAST:
Limit: 25 (cost=50843 rows=25) (actual time=3823..3823 rows=12)
-> Sort: BUILD_NUMBER DESC (cost=50843 rows=196252) (actual time=3823..3823 rows=12)
-> Filter: MARKED_FOR_DELETION=0 AND LIFE_CYCLE_STATE='Finished'
AND cast(BUILD_KEY as char)='AHNRT-HNRTADDP'
(cost=50843 rows=196252) (actual time=1998..3823 rows=12)
-> Intersect rows sorted by row ID (actual rows≈631,858/766,999)
Workaround
Currently there is no known workaround for this behavior. A workaround will be added here when available
- mentioned in
-
Page Loading...