From ec51ddaae772128f9d4a6c84b851b0e999a7d53c Mon Sep 17 00:00:00 2001 From: Valentin Rigal Date: Mon, 28 Aug 2023 13:30:55 +0200 Subject: [PATCH] Revert --- ...hed_0022_modify_bugscache_and_bugjobmap.py | 57 +++++++------------ treeherder/model/models.py | 13 ++--- 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/treeherder/model/migrations/0001_squashed_0022_modify_bugscache_and_bugjobmap.py b/treeherder/model/migrations/0001_squashed_0022_modify_bugscache_and_bugjobmap.py index 913c3b5efef..919060e0d8d 100644 --- a/treeherder/model/migrations/0001_squashed_0022_modify_bugscache_and_bugjobmap.py +++ b/treeherder/model/migrations/0001_squashed_0022_modify_bugscache_and_bugjobmap.py @@ -40,49 +40,30 @@ 'DROP INDEX failure_line_signature_test_idx ON failure_line;', ], state_operations=[ - migrations.AddIndex( - model_name='failureline', - index=django.contrib.postgres.indexes.HashIndex( - fields=['test', 'subtest', 'status', 'expected', 'created'], - name='failure_lin_test_52689e_hash', - ), - ), - migrations.AddIndex( - model_name='failureline', - index=django.contrib.postgres.indexes.HashIndex( - fields=['signature', 'test', 'created'], - name='failure_lin_signatu_69323a_hash', - ), - ), - migrations.AddIndex( - model_name='failureline', - index=models.Index( - fields=['job_guid', 'repository'], name='failure_lin_job_gui_b67c6d_idx' + migrations.AlterIndexTogether( + name='failureline', + index_together=set( + [ + ('test', 'subtest', 'status', 'expected', 'created'), + ('job_guid', 'repository'), + ('signature', 'test', 'created'), + ] ), ), ], ), ] else: + # On postgres we can use standard migrations EXTRA_MIGRATIONS = [ - migrations.AddIndex( - model_name='failureline', - index=django.contrib.postgres.indexes.HashIndex( - fields=['test', 'subtest', 'status', 'expected', 'created'], - name='failure_lin_test_52689e_hash', - ), - ), - migrations.AddIndex( - model_name='failureline', - index=django.contrib.postgres.indexes.HashIndex( - fields=['signature', 'test', 'created'], - name='failure_lin_signatu_69323a_hash', - ), - ), - migrations.AddIndex( - model_name='failureline', - index=models.Index( - fields=['job_guid', 'repository'], name='failure_lin_job_gui_b67c6d_idx' + migrations.AlterIndexTogether( + name='failureline', + index_together=set( + [ + ('test', 'subtest', 'status', 'expected', 'created'), + ('job_guid', 'repository'), + ('signature', 'test', 'created'), + ] ), ), migrations.AddIndex( @@ -1038,6 +1019,10 @@ class Migration(migrations.Migration): name='failureline', unique_together=set([('job_log', 'line')]), ), + migrations.AlterIndexTogether( + name='failureline', + index_together=set([('job_guid', 'repository')]), + ), migrations.AlterUniqueTogether( name='commit', unique_together=set([('push', 'revision')]), diff --git a/treeherder/model/models.py b/treeherder/model/models.py index 311b4612acd..273995a30ff 100644 --- a/treeherder/model/models.py +++ b/treeherder/model/models.py @@ -14,7 +14,6 @@ from django.conf import settings from django.contrib.auth.models import User from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector -from django.contrib.postgres.indexes import HashIndex from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist from django.core.validators import MinLengthValidator @@ -956,12 +955,12 @@ class FailureLine(models.Model): class Meta: db_table = 'failure_line' - indexes = ( - # Hash function is required to index large entries in test and subtest fields - # https://www.postgresql.org/docs/15/textsearch-limitations.html - HashIndex(fields=('test', 'subtest', 'status', 'expected', 'created')), - HashIndex(fields=('signature', 'test', 'created')), - models.Index(fields=('job_guid', 'repository')), + index_together = ( + ('job_guid', 'repository'), + # Prefix index: test(50), subtest(25), status, expected, created + ('test', 'subtest', 'status', 'expected', 'created'), + # Prefix index: signature(25), test(50), created + ('signature', 'test', 'created'), ) unique_together = ('job_log', 'line')