PhoenixKit V21 Migration: Optimize Message ID Search Performance
This migration adds a composite index on (message_id, aws_message_id) to optimize the dual message ID search pattern used throughout the email system.
Changes
Email System Performance Optimization
- Adds composite index on (message_id, aws_message_id) for faster lookups
- Improves performance of AWS SES event correlation
- Optimizes message ID search queries used in SQSProcessor and EmailLog
Background
The email system uses a dual message ID architecture:
message_id: Internal PhoenixKit ID (pk_ prefix) - primary identifieraws_message_id: AWS SES ID - secondary identifier for AWS event correlation
This composite index enables fast searches when querying either field or both, which is critical for processing AWS SES events and correlating them with email logs.
PostgreSQL Support
- Supports PostgreSQL prefix for schema isolation
- Uses efficient B-tree index for string matching
- Backward compatible with existing data