Merge lp:~canonical-isd-hackers/canonical-identity-provider/long-query into lp:canonical-identity-provider/release

Proposed by David Owen
Status: Merged
Approved by: Danny Tamez
Approved revision: no longer in the source branch.
Merged at revision: 233
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/long-query
Merge into: lp:canonical-identity-provider/release
Diff against target: 19 lines (+3/-1)
2 files modified
SCHEMA_CHANGES.txt (+2/-0)
identityprovider/models/authtoken.py (+1/-1)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/long-query
Reviewer Review Type Date Requested Status
Danny Tamez (community) Approve
Ricardo Kirkner Pending
Review via email: mp+82229@code.launchpad.net

Commit message

Index AuthToken's e-mail field, for quickly nullifying other tokens for a single address.

Description of the change

IMPORTANT NOTE: I based this revision off of the last revno in trunk that was from stable. This patch could be applied directly to stable, as we may want this change on production before deploying the newer features in trunk.

SSO has one query that takes up way more time than any other. This index enables that query to do a O(log N) index scan instead of an O(N) table scan, speeding it up by several orders of magnitude.

We don't currently have a way to manage migrations for SSO, so I added the effective changes (derived from Django's actual output) to SCHEMA_CHANGES.txt.

To post a comment you must log in.
Revision history for this message
Danny Tamez (zematynnad) wrote :

Looks fine!

review: Approve
Revision history for this message
David Owen (dsowen) wrote :

@ricardo

IMO, unless we're ready to push the rest of trunk into the staging->production pipeline, then this patch should circumvent that so we can get its benefits more quickly.

Opinion?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'SCHEMA_CHANGES.txt'
2--- SCHEMA_CHANGES.txt 1970-01-01 00:00:00 +0000
3+++ SCHEMA_CHANGES.txt 2011-11-14 22:31:24 +0000
4@@ -0,0 +1,2 @@
5+CREATE INDEX authtoken_email ON authtoken USING btree (email);
6+CREATE INDEX authtoken_email_like ON authtoken USING btree (email text_pattern_ops);
7
8=== modified file 'identityprovider/models/authtoken.py'
9--- identityprovider/models/authtoken.py 2011-07-27 13:00:22 +0000
10+++ identityprovider/models/authtoken.py 2011-11-14 22:31:24 +0000
11@@ -48,7 +48,7 @@
12 requester = models.ForeignKey(Account, db_column='requester',
13 null=True, blank=True)
14 requester_email = models.TextField(null=True, blank=True)
15- email = models.TextField()
16+ email = models.TextField(db_index=True)
17 redirection_url = models.TextField(null=True, blank=True)
18
19 displayname = DisplaynameField(null=True)