StaticDiff is unused and needs to be shot

Bug #834384 reported by Steve Kowalik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Low
Steve Kowalik

Bug Description

StaticDiff is unused, and the last row was added to the table in January 2010. The table is only 30k rows, and roughly 20k of those are not linked to BranchMergeProposal.

We can migrate the linked rows from StaticDiff to PreviewDiffs by the following SQL:

CREATE INDEX temp_previewdiff ON previewdiff(source_revision_id, target_revision_id); (Index creation may not be needed)

INSERT INTO previewdiff (source_revision_id, target_revision_id, diff) SELECT from_revision_id, to_revision_id, diff FROM staticdiff WHERE id IN (SELECT review_diff FROM branchmergeproposal WHERE review_diff IS NOT NULL AND merge_diff IS NULL); (expecting 5,213 rows)

UPDATE branchmergeproposal SET merge_diff = (SELECT id FROM previewdiff WHERE from_revision_id = source_revision_id AND to_revision_id = target_revision_id) FROM staticdiff WHERE staticdiff.id = review_diff AND merge_diff IS NULL; (expecting 5,251 rows)

UPDATE branchmergeproposal SET review_diff = null WHERE review_diff IS NOT NULL AND merge_diff IS NOT NULL; (expecting 12,111 rows)

ALTER TABLE branchmergeproposal DROP CONSTRAINT branchmergeproposal_review_diff_fkey; (drop the FK)

Tags: qa-ok

Related branches

Steve Kowalik (stevenk)
description: updated
Revision history for this message
Stuart Bishop (stub) wrote :

If we create a temporary index, we need to drop it.

Due to the ALTER TABLE, this is a downtime db patch.

Revision history for this message
William Grant (wgrant) wrote :

The ALTER TABLE will be done separately, at the same time as the other 30 unused tables.

Revision history for this message
Stuart Bishop (stub) wrote :

Don't bother with creating the index. It will take more time than it will save.

Revision history for this message
William Grant (wgrant) wrote :

Have you confirmed that on staging? On DF it was doing thousands of seq scans, AFAICT.

Revision history for this message
Stuart Bishop (stub) wrote :

Migration has been made live using https://pastebin.canonical.com/52285/ (with added transactions and statement timeouts)

Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Changed in launchpad:
assignee: nobody → Steve Kowalik (stevenk)
tags: added: qa-needstesting
Changed in launchpad:
status: Confirmed → Fix Committed
Revision history for this message
William Grant (wgrant) wrote :

New MP diffs work fine on qastaging, and added/removed/new branchmail still works.

tags: added: qa-ok
removed: qa-needstesting
Gary Poster (gary)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.