Skip to main content
Knowledge Base
For Developers

Prisma Optimization

Approach to keeping database queries fast and analytics responsive.

Optimization principles

  • Server-side aggregation: Compute metrics close to the data source (PostgreSQL) rather than fetching raw rows and aggregating in the client
  • Read-optimized: The dashboard and reports are read-heavy. Queries are optimized for these paths.
  • Intentional query shape: Use reusable aggregation helpers instead of ad-hoc calculations
  • Selective includes: Use Prisma's include and select carefully to avoid overfetching

Common patterns

  • Batch loading for trade lists
  • Cached aggregation results for KPI computations
  • Indexed columns for frequently filtered fields (user_id, account_id, date)
  • Paginated queries for trade tables using cursor-based pagination