sendalerts was not using the api_check (status, user_id, alert_after) index so removing it. The index was not selective enough.

This commit is contained in:
Pēteris Caune 2018-01-17 00:49:03 +02:00
parent c4b316003d
commit 1392226538
3 changed files with 20 additions and 6 deletions

View File

@ -28,7 +28,7 @@ def notify_on_thread(check_id, stdout):
class Command(BaseCommand):
help = 'Sends UP/DOWN email alerts'
owned = Check.objects.filter(user__isnull=False)
owned = Check.objects.filter(user__isnull=False).order_by("alert_after")
def add_arguments(self, parser):
parser.add_argument(

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-01-16 22:43
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0035_auto_20171229_2008'),
]
operations = [
migrations.AlterIndexTogether(
name='check',
index_together=set([]),
),
]

View File

@ -57,11 +57,6 @@ def isostring(dt):
class Check(models.Model):
class Meta:
# sendalerts command will query using these
index_together = ["status", "user", "alert_after"]
name = models.CharField(max_length=100, blank=True)
tags = models.CharField(max_length=500, blank=True)
code = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True)