Repository: Cloud-CV/EvalAI

Issue:
Add indexing in database.



Discussion:
Hello,

Is anyone already working on this? I will like to look into it.

Resolving patch:
diff --git a/apps/jobs/migrations/0006_add_indexing_to_some_attributes.py b/apps/jobs/migrations/0006_add_indexing_to_some_attributes.py
new file mode 100644
--- /dev/null
+++ b/apps/jobs/migrations/0006_add_indexing_to_some_attributes.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.2 on 2017-09-15 03:19
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('jobs', '0005_added_new_fields_to_submission_model'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='submission',
+            name='completed_at',
+            field=models.DateTimeField(blank=True, db_index=True, null=True),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='execution_time_limit',
+            field=models.PositiveIntegerField(db_index=True, default=300),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='method_description',
+            field=models.TextField(blank=True, db_index=True, null=True),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='method_name',
+            field=models.CharField(db_index=True, max_length=1000, null=True),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='project_url',
+            field=models.CharField(db_index=True, max_length=1000, null=True),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='publication_url',
+            field=models.CharField(db_index=True, max_length=1000, null=True),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='started_at',
+            field=models.DateTimeField(blank=True, db_index=True, null=True),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='status',
+            field=models.CharField(choices=[('submitted', 'submitted'), ('running', 'running'), ('failed', 'failed'), ('cancelled', 'cancelled'), ('finished', 'finished'), ('submitting', 'submitting')], db_index=True, max_length=30),
+        ),
+        migrations.AlterField(
+            model_name='submission',
+            name='submitted_at',
+            field=models.DateTimeField(auto_now_add=True, db_index=True),
+        ),
+    ]
diff --git a/apps/jobs/models.py b/apps/jobs/models.py
--- a/apps/jobs/models.py
+++ b/apps/jobs/models.py
@@ -64,14 +64,14 @@ class Submission(TimeStampedModel):
     challenge_phase = models.ForeignKey(
         ChallengePhase, related_name='submissions')
     created_by = models.ForeignKey(User)
-    status = models.CharField(max_length=30, choices=STATUS_OPTIONS)
+    status = models.CharField(max_length=30, choices=STATUS_OPTIONS, db_index=True)
     is_public = models.BooleanField(default=False)
     submission_number = models.PositiveIntegerField(default=0)
     download_count = models.IntegerField(default=0)
     output = models.TextField(blank=True, null=True)
-    submitted_at = models.DateTimeField(auto_now_add=True)
-    started_at = models.DateTimeField(null=True, blank=True)
-    completed_at = models.DateTimeField(null=True, blank=True)
+    submitted_at = models.DateTimeField(auto_now_add=True, db_index=True)
+    started_at = models.DateTimeField(null=True, blank=True, db_index=True)
+    completed_at = models.DateTimeField(null=True, blank=True, db_index=True)
     when_made_public = models.DateTimeField(null=True, blank=True)
     input_file = models.FileField(upload_to=RandomFileName("submission_files/submission_{id}"))
     stdout_file = models.FileField(upload_to=RandomFileName("submission_files/submission_{id}"), null=True, blank=True)
@@ -80,11 +80,11 @@ class Submission(TimeStampedModel):
         upload_to=RandomFileName("submission_files/submission_{id}"), null=True, blank=True)
     submission_metadata_file = models.FileField(
         upload_to=RandomFileName("submission_files/submission_{id}"), null=True, blank=True)
-    execution_time_limit = models.PositiveIntegerField(default=300)
-    method_name = models.CharField(max_length=1000, null=True)
-    method_description = models.TextField(blank=True, null=True)
-    publication_url = models.CharField(max_length=1000, null=True)
-    project_url = models.CharField(max_length=1000, null=True)
+    execution_time_limit = models.PositiveIntegerField(default=300, db_index=True)
+    method_name = models.CharField(max_length=1000, null=True, db_index=True)
+    method_description = models.TextField(blank=True, null=True, db_index=True)
+    publication_url = models.CharField(max_length=1000, null=True, db_index=True)
+    project_url = models.CharField(max_length=1000, null=True, db_index=True)
 
     def __unicode__(self):
         return '{}'.format(self.id)


Test patch: