Performance improvement - add foreign key indexes

Created by: danielkummer

Hi We're using gitlabhq quite intensively at our company. I notices increasingly bad performance directly related to the mysql database.

After analyzing the queries with the slow log i came to the conclusion that a few extra indices would speed up the application significantly.

I suggest adding indices to the foreign keys of the tables.

I got a massive performance gain just by adding an index to the project_id column of the events table:

ALTER TABLE events ADD INDEX project_id (project_id)