Skip to content

Performance: Missing Database Indexes #891

@vjpixel

Description

@vjpixel

Medium Performance Issue

Missing database indexes on frequently queried fields.

File: Database migrations
Severity: MEDIUM
Impact: Slow query performance

Issues Found:

  1. No index on user_id in objects table
  2. No index on created_at for sorting
  3. Missing composite indexes

Suggested Fix

Add database indexes:

# In migration file
operations = [
    migrations.RunSQL(
        "CREATE INDEX CONCURRENTLY idx_objects_user_id ON core_object(user_id);",
        reverse_sql="DROP INDEX IF EXISTS idx_objects_user_id;"
    ),
    migrations.RunSQL(
        "CREATE INDEX CONCURRENTLY idx_objects_created_at ON core_object(created_at DESC);",
        reverse_sql="DROP INDEX IF EXISTS idx_objects_created_at;"
    ),
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: mediumMedium priority - standard priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions