travis-ci/travis-core — pull request #349 by henrikhodne (2014-02-10 06:44:37+00:00)
Title: feat(db): add index on memberships(user_id)

One of the queries having taken the longest total time on our production DB is finding the organizations for a given user. This index should speed that query up significantly.

```
total_minutes | 563.453483033315
average_time | 9.17474210550139
query | SELECT "organizations".* FROM "organizations" INNER JOIN "memberships" ON "organizations"."id" = "memberships"."organization_id" WHERE "memberships"."user_id" = ?
```

Granted, 9 ms as an average time is not *slow*, but given the fact that it's being called often enough for the 'total_minutes' to be this high makes me think it might still be worth it.