Perf: Add composite database indexes for common queries
Add indexes for: - (AccountId, Category) - account spending by category - (AccountId, Date) - account transaction timelines - (MerchantId, Date) - merchant spending trends - (CardId, Date) - card activity analysis - FileHashSha256 on Receipts - duplicate detection - (TransactionId, ReceiptDate) on Receipts - receipt lookups 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -195,6 +195,16 @@ namespace MoneyMap.Data
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => x.Amount);
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => x.Category);
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => x.MerchantId);
|
||||
|
||||
// Composite indexes for common query patterns
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => new { x.AccountId, x.Category });
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => new { x.AccountId, x.Date });
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => new { x.MerchantId, x.Date });
|
||||
modelBuilder.Entity<Transaction>().HasIndex(x => new { x.CardId, x.Date });
|
||||
|
||||
// Receipt duplicate detection and lookup
|
||||
modelBuilder.Entity<Receipt>().HasIndex(x => x.FileHashSha256);
|
||||
modelBuilder.Entity<Receipt>().HasIndex(x => new { x.TransactionId, x.ReceiptDate });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user