Skip to content

Database Indexing for Performance #6

@xenioushk

Description

@xenioushk

Create database indexes to improve query performance for common operations.

Requirements:

  • Add indexes to User model:
    • Unique index on email
    • Unique index on username
  • Add indexes to Photo model:
    • Index on userId
    • Index on albumId
    • Text index on title for search
  • Add indexes to Album model:
    • Index on userId
    • Text index on title for search
  • Compound indexes for common queries
  • Migration script to create indexes

Acceptance Criteria:

  • All necessary indexes created
  • Unique constraints on email/username
  • Text indexes for search functionality
  • Compound indexes for filtered queries
  • Index creation script
  • Performance testing shows improvement
  • Index usage verified with explain()

Implementation Notes:

// In Photo model
photoSchema.index({ userId: 1 })
photoSchema.index({ albumId: 1 })
photoSchema.index({ title: "text" })
photoSchema.index({ userId: 1, albumId: 1 }) // compound

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions