Skip to content

Optimize database queries #295

@yomete

Description

@yomete

Is your feature request related to a problem?
PostgreSQL compute costs can be high due to expensive database queries. The current implementation uses SELECT * for all queries, resulting in 60-70% higher CPU usage than necessary. This leads to significant hosting cost increases, especially for photo-heavy applications.

Describe the feature/solution you'd like
Database query optimizations that reduce PostgreSQL CPU usage by implementing:

  • Context-specific column selection (grid/admin/detail views only fetch needed
    columns)
  • Connection pooling optimization

I've implemented these optimizations and achieved a 67% reduction in compute usage ($20/month savings) with no functionality regressions after 3+ months in production.

Image

Neon database billing before optimizations

Image Image

Neon database billing after optimizations

Image Image

Live deployment
https://pics.yomieluwan.de

Would you be interested in a PR with these optimizations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceSomething isn't fast or efficient enough

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions