π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[MOB-1199] dev: update index constraints for notifications to optimize query performance (#7870)
guru_sainathe36f4f47f16c
diff --git a/apps/api/plane/db/migrations/0111_notification_notif_receiver_status_idx_and_more.py b/apps/api/plane/db/migrations/0111_notification_notif_receiver_status_idx_and_more.pynew file mode 100644index 0000000000..5ceb1f36c0--- /dev/null+++ b/apps/api/plane/db/migrations/0111_notification_notif_receiver_status_idx_and_more.py@@ -0,0 +1,39 @@+# Generated by Django 4.2.22 on 2025-09-29 15:36++from django.db import migrations, models+from django.contrib.postgres.operations import AddIndexConcurrently+++class Migration(migrations.Migration):+ atomic = False++ dependencies = [+ ('db', '0110_workspaceuserproperties_navigation_control_preference_and_more'),+ ]++ operations = [+ AddIndexConcurrently(+ model_name='notification',+ index=models.Index(fields=['receiver', 'workspace', 'read_at', 'created_at'], name='notif_receiver_status_idx'),+ ),+ AddIndexConcurrently(+ model_name='notification',+ index=models.Index(fields=['receiver', 'workspace', 'entity_name', 'read_at'], name='notif_receiver_entity_idx'),+ ),+ AddIndexConcurrently(+ model_name='notification',+ index=models.Index(fields=['receiver', 'workspace', 'snoozed_till', 'archived_at'], name='notif_receiver_state_idx'),+ ),+ AddIndexConcurrently(+ model_name='notification',+ index=models.Index(fields=['receiver', 'workspace', 'sender'], name='notif_receiver_sender_idx'),+ ),+ AddIndexConcurrently(+ model_name='notification',+ index=models.Index(fields=['workspace', 'entity_identifier', 'entity_name'], name='notif_entity_lookup_idx'),+ ),+ AddIndexConcurrently(+ model_name='fileasset',+ index=models.Index(fields=['asset'], name='asset_asset_idx'),+ ),+ ]diff --git a/apps/api/plane/db/models/asset.py b/apps/api/plane/db/models/asset.pyindex 1de0f18b40..ed9879a733 100644--- a/apps/api/plane/db/models/asset.py+++ b/apps/api/plane/db/models/asset.py@@ -66,6 +66,7 @@ class FileAsset(BaseModel):models.Index(fields=["entity_type"], name="asset_entity_type_idx"),models.Index(fields=["entity_identifier"], name="asset_entity_identifier_idx"),models.Index(fields=["entity_type", "entity_identifier"], name="asset_entity_idx"),+ models.Index(fields=["asset"], name="asset_asset_idx"),]def __str__(self):diff --git a/apps/api/plane/db/models/notification.py b/apps/api/plane/db/models/notification.pyindex aa58bc30cf..fd97a3c968 100644--- a/apps/api/plane/db/models/notification.py+++ b/apps/api/plane/db/models/notification.py@@ -38,6 +38,26 @@ class Notification(BaseModel):models.Index(fields=["entity_name"], name="notif_entity_name_idx"),models.Index(fields=["read_at"], name="notif_read_at_idx"),models.Index(fields=["receiver", "read_at"], name="notif_entity_idx"),+ models.Index(+ fields=["receiver", "workspace", "read_at", "created_at"],+ name="notif_receiver_status_idx",+ ),+ models.Index(+ fields=["receiver", "workspace", "entity_name", "read_at"],+ name="notif_receiver_entity_idx",+ ),+ models.Index(+ fields=["receiver", "workspace", "snoozed_till", "archived_at"],+ name="notif_receiver_state_idx",+ ),+ models.Index(+ fields=["receiver", "workspace", "sender"],+ name="notif_receiver_sender_idx",+ ),+ models.Index(+ fields=["workspace", "entity_identifier", "entity_name"],+ name="notif_entity_lookup_idx",+ ),]def __str__(self):