Add database indexes to opsce entity columns for query performance#858
Merged
Conversation
Add database indexes to opsce entity columns for query performance
|
@MaryammAli is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@MaryammAli Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
yusuftomilola
approved these changes
Jun 1, 2026
Collaborator
yusuftomilola
left a comment
There was a problem hiding this comment.
thanks for your contribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[BE-34] Add Database Indexes to OPSCE Entity Columns for Query Performance
Overview
This PR improves database query performance by adding indexes to frequently queried OPSCE entity columns. These indexes are designed to optimize filtering, sorting, pagination, and join operations as the dataset grows.
Problem Addressed
Several high-traffic entity fields used in
WHERE,ORDER BY, andJOINclauses currently lack database indexes. This can lead to full table scans, increased query latency, and degraded application performance as asset and audit data volumes increase.Changes Made
Asset Entity
Added
@Index()decorators to commonly queried asset fields:statuscategorydepartmentIdlocationIdassignedTocreatedAtThe
createdAtindex improves:AuditLog Entity
Added
@Index()decorators to:userIdresourceTypecreatedAtThese indexes optimize:
MaintenanceRecord Entity
Added
@Index()decorators to:assetIdscheduledDateThese indexes improve:
Database Migration
Performance Benefits
Acceptance Criteria
Asset.status,Asset.category,Asset.departmentId,Asset.locationId, andAsset.assignedTohave indexes.Asset.createdAtis indexed for pagination and date-range queries.AuditLog.userId,AuditLog.resourceType, andAuditLog.createdAthave indexes.MaintenanceRecord.assetIdandMaintenanceRecord.scheduledDatehave indexes.Notes
Closes [BE-34] Add database indexes to opsce entity columns for query performance #759