Skip to content

Commit

Permalink
Optimize query for latest pnl tick at specific time. (backport #2599) (
Browse files Browse the repository at this point in the history
…#2605)

Co-authored-by: vincentwschau <99756290+vincentwschau@users.noreply.github.com>
  • Loading branch information
mergify[bot] and vincentwschau authored Nov 25, 2024
1 parent bf515a6 commit 676fb08
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 676fb08

Please sign in to comment.