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

Subscribers

People subscribed via source and target branches

to status/vote changes: