Repository: pulp/pulpcore

Issue:
Missing database indices for the checksum fields in `RemoteArtifact`
**Version**
pulpcore 3.21+

**Describe the bug**
The checksum fields in the `RemoteArtifact` model are missing a `db_index` compared to the `Artifact` model.

**Expected behavior**
To improve query performance it would be great to have access to a index here as well.



Discussion:

Resolving patch:
diff --git a/pulpcore/app/migrations/0116_alter_remoteartifact_md5_alter_remoteartifact_sha1_and_more.py b/pulpcore/app/migrations/0116_alter_remoteartifact_md5_alter_remoteartifact_sha1_and_more.py
new file mode 100644
--- /dev/null
+++ b/pulpcore/app/migrations/0116_alter_remoteartifact_md5_alter_remoteartifact_sha1_and_more.py
@@ -0,0 +1,43 @@
+# Generated by Django 4.2.7 on 2023-12-04 15:58
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0115_compositecontentguard'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='remoteartifact',
+            name='md5',
+            field=models.CharField(db_index=True, max_length=32, null=True),
+        ),
+        migrations.AlterField(
+            model_name='remoteartifact',
+            name='sha1',
+            field=models.CharField(db_index=True, max_length=40, null=True),
+        ),
+        migrations.AlterField(
+            model_name='remoteartifact',
+            name='sha224',
+            field=models.CharField(db_index=True, max_length=56, null=True),
+        ),
+        migrations.AlterField(
+            model_name='remoteartifact',
+            name='sha256',
+            field=models.CharField(db_index=True, max_length=64, null=True),
+        ),
+        migrations.AlterField(
+            model_name='remoteartifact',
+            name='sha384',
+            field=models.CharField(db_index=True, max_length=96, null=True),
+        ),
+        migrations.AlterField(
+            model_name='remoteartifact',
+            name='sha512',
+            field=models.CharField(db_index=True, max_length=128, null=True),
+        ),
+    ]
diff --git a/pulpcore/app/models/content.py b/pulpcore/app/models/content.py
--- a/pulpcore/app/models/content.py
+++ b/pulpcore/app/models/content.py
@@ -713,12 +713,12 @@ class RemoteArtifact(BaseModel, QueryMixin):
 
     url = models.TextField(validators=[validators.URLValidator])
     size = models.BigIntegerField(null=True)
-    md5 = models.CharField(max_length=32, null=True)
-    sha1 = models.CharField(max_length=40, null=True)
-    sha224 = models.CharField(max_length=56, null=True)
-    sha256 = models.CharField(max_length=64, null=True)
-    sha384 = models.CharField(max_length=96, null=True)
-    sha512 = models.CharField(max_length=128, null=True)
+    md5 = models.CharField(max_length=32, null=True, db_index=True)
+    sha1 = models.CharField(max_length=40, null=True, db_index=True)
+    sha224 = models.CharField(max_length=56, null=True, db_index=True)
+    sha256 = models.CharField(max_length=64, null=True, db_index=True)
+    sha384 = models.CharField(max_length=96, null=True, db_index=True)
+    sha512 = models.CharField(max_length=128, null=True, db_index=True)
 
     content_artifact = models.ForeignKey(ContentArtifact, on_delete=models.CASCADE)
     remote = models.ForeignKey("Remote", on_delete=models.CASCADE)


Test patch: