Thanks. Will do a background index.
Scriptrunner times out in both tested environments but still completed the job in the background. The problem is it took 3.5 hours for the 100K+ update which is a slice of our production data.
Thanks for letting me know that there might be issues with my query. I didn’t really understand your solution but it’s a learning curve issue. Would you kindly output your SQL solution based on the details provided below?
The conversion is a varchar (255) to a longtext string. In Jira the customfield is being converted from a single-line textfield to a multi-line textfield. So there will be no truncation or conversion issues.
The custom fields have a 1:1 relationship as the new custom field has been added to every screen under the existing custom field. And the new custom field id will have a NULL value in the textvalue field. Some of the original field stringvalue records may also be NULL.
The table to be updated:
+-------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| ID | decimal(18,0) | NO | PRI | NULL | |
| ISSUE | decimal(18,0) | YES | MUL | NULL | |
| CUSTOMFIELD | decimal(18,0) | YES | | NULL | |
| PARENTKEY | varchar(255) | YES | | NULL | |
| STRINGVALUE | varchar(255) | YES | | NULL | |
| NUMBERVALUE | decimal(18,6) | YES | | NULL | |
| TEXTVALUE | longtext | YES | | NULL | |
| DATEVALUE | datetime | YES | | NULL | |
| VALUETYPE | varchar(255) | YES | | NULL | |
| UPDATED | decimal(18,0) | YES | | NULL | |
+-------------+---------------+------+-----+---------+-------+
Expected output before SQL update:
SELECT issue, customfield, stringvalue, textvalue
FROM customfieldvalue
WHERE customfield=123
OR customfield=456
ORDER BY issue
LIMIT 4;
# output:
+-------+-------------+-----------------------------+
| issue | customfield | stringvalue | textvalue |
+-------+-------------+-----------------------------+
| 10130 | 456 | lorem ipsum | NULL |
| 10130 | 123 | NULL | NULL |
| 12179 | 456 | si dolor est | NULL |
| 12179 | 123 | NULL | NULL |
+-------+-------------+-----------------------------+
Expected output after SQL update:
SELECT issue, customfield, stringvalue, textvalue
FROM customfieldvalue
WHERE customfield=123
OR customfield=456
ORDER BY issue
LIMIT 4;
# output goal:
+-------+-------------+-----------------------------+
| issue | customfield | stringvalue | textvalue |
+-------+-------------+-----------------------------+
| 10130 | 456 | lorem ipsum | NULL |
| 10130 | 123 | NULL | lorem ipsum |
| 12179 | 456 | si dolor est | NULL |
| 12179 | 123 | NULL | si dolor est |
+-------+-------------+-----------------------------+