Description
Calculating total volume, unique holders, and price histories using sequential Prisma queries leads to the N+1 problem and high API latency.
Architecture & Context
To serve the complex frontend dashboards, the database layer must leverage PostgreSQL Common Table Expressions (CTEs). A single, highly optimized raw SQL query should calculate the aggregate metrics for the fractional vaults, bypassing Prisma's object-mapping overhead for reads.
Technical Requirements
- Write raw SQL CTEs to aggregate share volume and historical pricing.
- Execute the query using Prisma's
$queryRaw method.
- Create a materialized view for data older than 24 hours.
Acceptance Criteria
Description
Calculating total volume, unique holders, and price histories using sequential Prisma queries leads to the N+1 problem and high API latency.
Architecture & Context
To serve the complex frontend dashboards, the database layer must leverage PostgreSQL Common Table Expressions (CTEs). A single, highly optimized raw SQL query should calculate the aggregate metrics for the fractional vaults, bypassing Prisma's object-mapping overhead for reads.
Technical Requirements
$queryRawmethod.Acceptance Criteria