feat: add indexes to DB CV models for easier search queries#43
feat: add indexes to DB CV models for easier search queries#43
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds database indexes to the CVQuestionnaire and AIResponse models to improve query performance for search operations. The changes include both individual field indexes and composite indexes for commonly queried field combinations.
- Added
db_index=Trueto frequently queried fields in both models - Created composite indexes in Meta classes for multi-field query optimization
- Consolidated field definitions to single lines for better readability
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cv/models.py | Added db_index parameters to fields and composite indexes in Meta classes for both CVQuestionnaire and AIResponse models |
| cv/migrations/0003_alter_airesponse_created_at_and_more.py | Auto-generated Django migration file to apply the database index changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| models.Index(fields=['user', 'submitted_at'], name='cv_user_submitted_idx'), | ||
| models.Index(fields=['position', 'industry'], name='cv_position_industry_idx'), | ||
| models.Index(fields=['experience_level', 'company_size'], name='cv_exp_company_idx'), | ||
| models.Index(fields=['submitted_at'], name='cv_submitted_at_idx'), |
There was a problem hiding this comment.
The single-field index on 'submitted_at' is redundant since 'submitted_at' is already covered by the composite index 'cv_user_submitted_idx' and has db_index=True on the field definition.
| models.Index(fields=['submitted_at'], name='cv_submitted_at_idx'), |
| class Meta: | ||
| indexes = [ | ||
| models.Index(fields=['questionnaire', 'created_at'], name='ai_quest_created_idx'), | ||
| models.Index(fields=['created_at'], name='ai_created_at_idx'), |
There was a problem hiding this comment.
The single-field index on 'created_at' is redundant since 'created_at' is already covered by the composite index 'ai_quest_created_idx' and has db_index=True on the field definition.
| models.Index(fields=['created_at'], name='ai_created_at_idx'), |
No description provided.