Skip to content

Commit

Permalink
Optimize query for latest pnl tick at specific time. (#2599)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau authored Nov 22, 2024
1 parent fefd10e commit 9a1cde3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion indexer/packages/postgres/src/stores/pnl-ticks-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ export async function getLatestPnlTick(
pnl_ticks
WHERE
"subaccountId" in (${subaccountIds.map((id: string) => { return `'${id}'`; }).join(',')}) AND
"blockTime" <= '${beforeOrAt.toUTC().toISO()}'::timestamp
"blockTime" <= '${beforeOrAt.toUTC().toISO()}'::timestamp AND
"blockTime" >= '${beforeOrAt.toUTC().minus({ hours: 4 }).toISO()}'::timestamp
ORDER BY
"subaccountId",
"blockTime" DESC
Expand Down

0 comments on commit 9a1cde3

Please sign in to comment.