Bug 1419777 - Fix timeouts when loading perfherder compare view (#2973)

We need an index for optimizing fetching datums by push id (mysql is
currently choosing the repository foreign key index, which is not
very selective at all)
This commit is contained in:
William Lachance 2017-11-22 14:05:12 -05:00 коммит произвёл GitHub
Родитель d1a1b300ed
Коммит 0f87d2e7b8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 26 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-22 18:14
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('model', '0018_superseded_to_textlogstep_enum'),
('perf', '0003_add_performance_signature_alert_change_type'),
]
operations = [
migrations.AlterIndexTogether(
name='performancedatum',
index_together=set([('repository', 'signature', 'push_timestamp'), ('repository', 'signature', 'push')]),
),
]

Просмотреть файл

@ -155,7 +155,12 @@ class PerformanceDatum(models.Model):
class Meta:
db_table = 'performance_datum'
index_together = ('repository', 'signature', 'push_timestamp')
index_together = [
# this should speed up the typical "get a range of performance datums" query
('repository', 'signature', 'push_timestamp'),
# this should speed up the compare view in treeherder (we only index on
# repository because we currently filter on it in the query)
('repository', 'signature', 'push')]
unique_together = ('repository', 'job', 'push', 'signature')
def save(self, *args, **kwargs):