Merge lp:~adeuring/launchpad/bug-739075-2 into lp:launchpad/db-devel

Proposed by Abel Deuring
Status: Merged
Approved by: Abel Deuring
Approved revision: no longer in the source branch.
Merged at revision: 10544
Proposed branch: lp:~adeuring/launchpad/bug-739075-2
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~adeuring/launchpad/bug-739075
Diff against target: 48 lines (+6/-8)
2 files modified
lib/lp/answers/model/question.py (+4/-6)
lib/lp/answers/model/questionsperson.py (+2/-2)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-739075-2
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+60768@code.launchpad.net

Commit message

[r=allenap][bug=739075] do not join Message in QuestionMessage related queries in order to find the owner of the message; use the new column QuestionMessage.owner instead.

Description of the change

This branch should fix bug 739075: Person:+questions timeouts. An
EXPLAIN ANALYZE for the long queries from the OOPS reports mentioned
in this bug show that much time is spent joining QuestionMessage and
the huge table Message.

The prerequisite branch lp:~adeuring/launchpad/bug-739075 adds the
column owner to QuestionMessage; similar to BugMessage. The content
of this column is a copy of questionmessage.message.owner.

The branch removes joins of Message in queries in
lp.answers.model.question and lp.answers.model.questionsperson, and
it replaces terms like "Message.owner=some_person" with
"QuestionMessage.owner=some_person".

Tests:

./bin/test answers -vv

(sorry, I did not bother to check which tests are actually necessary
-- answers related tests needed less than 5 minutes on my machine.)

no lint

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/answers/model/question.py'
2--- lib/lp/answers/model/question.py 2011-05-09 18:57:18 +0000
3+++ lib/lp/answers/model/question.py 2011-05-12 12:01:27 +0000
4@@ -904,10 +904,8 @@
5 particular person."""
6 joins = [
7 ("""LEFT OUTER JOIN QuestionMessage
8- ON QuestionMessage.question = Question.id"""),
9- ("""LEFT OUTER JOIN Message
10- ON QuestionMessage.message = Message.id
11- AND Message.owner = %s""" % sqlvalues(person))]
12+ ON QuestionMessage.question = Question.id
13+ AND QuestionMessage.owner = %s""" % sqlvalues(person))]
14 if self.project:
15 joins.extend(self.getProductJoins())
16
17@@ -938,7 +936,7 @@
18 AND Question.status IN %(owner_status)s)
19 OR (Question.owner != %(person)s AND
20 Question.status = %(open_status)s AND
21- Message.owner = %(person)s)
22+ QuestionMessage.owner = %(person)s)
23 )''' % sqlvalues(
24 person=self.needs_attention_from,
25 owner_status=[
26@@ -1149,7 +1147,7 @@
27 QuestionParticipation.ANSWERER: "Question.answerer = %s",
28 QuestionParticipation.SUBSCRIBER: "QuestionSubscription.person = %s",
29 QuestionParticipation.OWNER: "Question.owner = %s",
30- QuestionParticipation.COMMENTER: "Message.owner = %s",
31+ QuestionParticipation.COMMENTER: "QuestionMessage.owner = %s",
32 QuestionParticipation.ASSIGNEE: "Question.assignee = %s"}
33
34 def getConstraints(self):
35
36=== modified file 'lib/lp/answers/model/questionsperson.py'
37--- lib/lp/answers/model/questionsperson.py 2011-05-12 12:01:25 +0000
38+++ lib/lp/answers/model/questionsperson.py 2011-05-12 12:01:27 +0000
39@@ -50,8 +50,8 @@
40 UNION SELECT question FROM QuestionSubscription
41 WHERE person = %(personID)s
42 UNION SELECT question
43- FROM QuestionMessage JOIN Message ON (message = Message.id)
44- WHERE Message.owner = %(personID)s
45+ FROM QuestionMessage
46+ WHERE owner = %(personID)s
47 )""" % sqlvalues(personID=self.person.id),
48 clauseTables=['Question'], distinct=True))
49

Subscribers

People subscribed via source and target branches

to status/vote changes: