I think the following is better to populate the new column (it avoids the noise from the SELECT output, and will be faster as there is no stored procedure call overhead):
UPDATE Bug
SET latest_patch_uploaded = LatestPatch.datecreated
FROM (
SELECT BugAttachment.bug, max(Message.datecreated) AS datecreated
FROM BugAttachment, Message
WHERE BugAttachment.message = Message.id
AND BugAttachment.type = 1
GROUP BY BugAttachment.bug
) AS LatestPatch
WHERE LatestPatch.bug = Bug.id;
I think the following is better to populate the new column (it avoids the noise from the SELECT output, and will be faster as there is no stored procedure call overhead):
UPDATE Bug patch_uploaded = LatestPatch. datecreated datecreated) AS datecreated message = Message.id
SET latest_
FROM (
SELECT BugAttachment.bug, max(Message.
FROM BugAttachment, Message
WHERE BugAttachment.
AND BugAttachment.type = 1
GROUP BY BugAttachment.bug
) AS LatestPatch
WHERE LatestPatch.bug = Bug.id;
The index is good.