Skip to content

Commit

Permalink
Add indexes to speed up finding messages to process
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasmcnulty committed Jun 10, 2024
1 parent 619a6f2 commit 9d2d8dd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/smpp_gateway/migrations/0006_message_status_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2.13 on 2024-06-10 01:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("smpp_gateway", "0005_alter_mtmessagestatus_command_status"),
]

operations = [
migrations.AddIndex(
model_name="momessage",
index=models.Index(
condition=models.Q(("status", "new")),
fields=["status"],
name="mo_message_status_idx",
),
),
migrations.AddIndex(
model_name="mtmessage",
index=models.Index(
condition=models.Q(("status", "new")),
fields=["status"],
name="mt_message_status_idx",
),
),
]
16 changes: 16 additions & 0 deletions src/smpp_gateway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def __str__(self):

class Meta:
verbose_name = _("mobile-originated message")
indexes = (
models.Index(
# Allow for quick filtering of messages that need to be processed
fields=["status"],
name="mo_message_status_idx",
condition=models.Q(status="new"), # No way to access Status.NEW here?
),
)


class MTMessage(AbstractTimestampModel, models.Model):
Expand Down Expand Up @@ -77,6 +85,14 @@ def __str__(self):

class Meta:
verbose_name = _("mobile-terminated message")
indexes = (
models.Index(
# Allow for quick filtering of messages that need to be processed
fields=["status"],
name="mt_message_status_idx",
condition=models.Q(status="new"), # No way to access Status.NEW here?
),
)


class MTMessageStatus(AbstractTimestampModel, models.Model):
Expand Down

0 comments on commit 9d2d8dd

Please sign in to comment.