Skip to content

Comments

feat: add indexes to DB CV models for easier search queries#43

Merged
DimitrovK merged 1 commit intomainfrom
add-db-indexes
Oct 4, 2025
Merged

feat: add indexes to DB CV models for easier search queries#43
DimitrovK merged 1 commit intomainfrom
add-db-indexes

Conversation

@DimitrovK
Copy link
Contributor

No description provided.

@DimitrovK DimitrovK self-assigned this Oct 4, 2025
@DimitrovK DimitrovK requested a review from Copilot October 4, 2025 08:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=True to 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'),
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
models.Index(fields=['submitted_at'], name='cv_submitted_at_idx'),

Copilot uses AI. Check for mistakes.
class Meta:
indexes = [
models.Index(fields=['questionnaire', 'created_at'], name='ai_quest_created_idx'),
models.Index(fields=['created_at'], name='ai_created_at_idx'),
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
models.Index(fields=['created_at'], name='ai_created_at_idx'),

Copilot uses AI. Check for mistakes.
@DimitrovK DimitrovK changed the title feat: add indexes to DB models for easier search queries feat: add indexes to DB CV models for easier search queries Oct 4, 2025
@DimitrovK DimitrovK merged commit e6eb9c6 into main Oct 4, 2025
1 check failed
@DimitrovK DimitrovK deleted the add-db-indexes branch October 4, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant