Merge lp:~wgrant/launchpad/flatten-bfj-0-db into lp:launchpad/db-devel

Proposed by William Grant
Status: Merged
Merged at revision: 12306
Proposed branch: lp:~wgrant/launchpad/flatten-bfj-0-db
Merge into: lp:launchpad/db-devel
Diff against target: 94 lines (+79/-0)
2 files modified
database/schema/patch-2209-41-0.sql (+78/-0)
database/schema/security.cfg (+1/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/flatten-bfj-0-db
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Review via email: mp+145540@code.launchpad.net

Commit message

Add performance denorm columns to BinaryPackageBuild/SourcePackageRecipeBuild/TranslationTemplatesBuild.

Description of the change

The build farm job schema is being reworked to improve performance. Columns from PackageBuild and BuildFarmJob are being merged into tables that previously delegated to them. The PackageBuild table will end up dying entirely, but BuildFarmJob will remain, a shadow of its former self, to answer questions about Archive:+builds and Builder:+history. Additionally, BinaryPackageBuild is growing new distribution, distroseries, sourcepackagename and is_distro_archive columns to make searches even faster.

This branch contains the main DB changes. BPB and SPRB gain all columns that previously lived on BFJ and PB, and TTB gets everything from BFJ. BPB and SPRB get direct FKs to BFJ, and their FKs to PB become nullable. BFJ gains an archive column to replace PB for use in Archive:+builds, failure_count becomes nullable as it's to be dropped soon, and the started_if_finished constraint dies because date_started is about to as well.

Additionally, BPB gains distribution, distroseries, sourcepackagename and is_distro_archive columns for more efficient searches.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

You need indexes on all of the log and upload_log columns or the Librarian Garbage Collector will hate you. This will need to be landed separately and applied live straight after, as there are a several million existing rows.

You can't default date_created and failure_count columns when creating the column without rewriting the entire tables and their indexes. Add the DEFAULTs using separate ALTER TABLE statements and you will be fine.

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2209-41-0.sql'
2--- database/schema/patch-2209-41-0.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2209-41-0.sql 2013-02-03 03:11:26 +0000
4@@ -0,0 +1,78 @@
5+-- Copyright 2013 Canonical Ltd. This software is licensed under the
6+-- GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+SET client_min_messages=ERROR;
9+
10+ALTER TABLE binarypackagebuild
11+ ADD COLUMN archive integer REFERENCES archive,
12+ ADD COLUMN pocket integer,
13+ ADD COLUMN processor integer REFERENCES processor,
14+ ADD COLUMN virtualized boolean,
15+ ADD COLUMN date_created timestamp without time zone,
16+ ADD COLUMN date_started timestamp without time zone,
17+ ADD COLUMN date_finished timestamp without time zone,
18+ ADD COLUMN date_first_dispatched timestamp without time zone,
19+ ADD COLUMN builder integer REFERENCES builder,
20+ ADD COLUMN status integer,
21+ ADD COLUMN log integer REFERENCES libraryfilealias,
22+ ADD COLUMN upload_log integer REFERENCES libraryfilealias,
23+ ADD COLUMN dependencies text,
24+ ADD COLUMN failure_count integer,
25+ ADD COLUMN build_farm_job integer REFERENCES buildfarmjob,
26+ ADD COLUMN distribution integer REFERENCES distribution,
27+ ADD COLUMN distro_series integer REFERENCES distroseries,
28+ ADD COLUMN is_distro_archive boolean,
29+ ADD COLUMN source_package_name integer REFERENCES sourcepackagename,
30+ ALTER COLUMN package_build DROP NOT NULL;
31+ALTER TABLE binarypackagebuild
32+ ALTER COLUMN date_created
33+ SET DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
34+ ALTER COLUMN failure_count SET DEFAULT 0;
35+
36+ALTER TABLE sourcepackagerecipebuild
37+ ADD COLUMN archive integer REFERENCES archive,
38+ ADD COLUMN pocket integer,
39+ ADD COLUMN processor integer REFERENCES processor,
40+ ADD COLUMN virtualized boolean,
41+ ADD COLUMN date_created timestamp without time zone,
42+ ADD COLUMN date_started timestamp without time zone,
43+ ADD COLUMN date_finished timestamp without time zone,
44+ ADD COLUMN date_first_dispatched timestamp without time zone,
45+ ADD COLUMN builder integer REFERENCES builder,
46+ ADD COLUMN status integer,
47+ ADD COLUMN log integer REFERENCES libraryfilealias,
48+ ADD COLUMN upload_log integer REFERENCES libraryfilealias,
49+ ADD COLUMN dependencies text,
50+ ADD COLUMN failure_count integer,
51+ ADD COLUMN build_farm_job integer REFERENCES buildfarmjob,
52+ ALTER COLUMN package_build DROP NOT NULL;
53+ALTER TABLE sourcepackagerecipebuild
54+ ALTER COLUMN date_created
55+ SET DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
56+ ALTER COLUMN failure_count SET DEFAULT 0;
57+
58+ALTER TABLE translationtemplatesbuild
59+ ADD COLUMN processor integer REFERENCES processor,
60+ ADD COLUMN virtualized boolean,
61+ ADD COLUMN date_created timestamp without time zone,
62+ ADD COLUMN date_started timestamp without time zone,
63+ ADD COLUMN date_finished timestamp without time zone,
64+ ADD COLUMN date_first_dispatched timestamp without time zone,
65+ ADD COLUMN builder integer REFERENCES builder,
66+ ADD COLUMN status integer,
67+ ADD COLUMN log integer REFERENCES libraryfilealias,
68+ ADD COLUMN failure_count integer;
69+ALTER TABLE sourcepackagerecipebuild
70+ ALTER COLUMN date_created
71+ SET DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'),
72+ ALTER COLUMN failure_count SET DEFAULT 0;
73+
74+-- BuildFarmJob is becoming a shadow of its former self, so more columns
75+-- have to be nullable, but it also grows an archive column to hasten
76+-- access checks.
77+ALTER TABLE buildfarmjob
78+ ADD COLUMN archive integer REFERENCES archive,
79+ ALTER COLUMN failure_count DROP NOT NULL,
80+ DROP CONSTRAINT started_if_finished;
81+
82+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 41, 0);
83
84=== modified file 'database/schema/security.cfg'
85--- database/schema/security.cfg 2013-01-15 05:24:27 +0000
86+++ database/schema/security.cfg 2013-02-03 03:11:26 +0000
87@@ -444,6 +444,7 @@
88 public.subunitstream = SELECT
89 public.temporaryblobstorage = SELECT, DELETE
90 public.translationimportqueueentry = SELECT
91+public.translationtemplatesbuild = SELECT
92 type=user
93
94 [productreleasefinder]

Subscribers

People subscribed via source and target branches

to status/vote changes: