client gives timeout when requesting top returns for larger universes #19

Closed
opened 2026-02-26 12:41:49 +00:00 by gertjan · 2 comments
gertjan commented 2026-02-26 12:41:49 +00:00 (Migrated from gitlab.esvedra.one)

Bodega> analytics top --sector Technology --exchange NASDAQ Connection error: The read operation timed out

`Bodega> analytics top --sector Technology --exchange NASDAQ Connection error: The read operation timed out`
fabioth commented 2026-02-27 10:50:11 +00:00 (Migrated from gitlab.esvedra.one)

marked this issue as related to #21

marked this issue as related to #21
gertjan (Migrated from gitlab.esvedra.one) closed this issue 2026-02-27 18:50:14 +00:00
project_1_bot_053fc026be1655bf3cd800152d0cdead commented 2026-02-27 19:02:34 +00:00 (Migrated from gitlab.esvedra.one)

Fixed in 702749b by rewriting get_top_performers to use TimescaleDB's native first(close, timestamp) / last(close, timestamp) aggregates instead of two separate DISTINCT ON CTEs. This halves the number of table scans and aligns with the compression layout (segmentby='symbol, granularity'), which was the root cause of the timeout for large universes like NASDAQ or Technology globally.

Fixed in 702749b by rewriting `get_top_performers` to use TimescaleDB's native `first(close, timestamp)` / `last(close, timestamp)` aggregates instead of two separate `DISTINCT ON` CTEs. This halves the number of table scans and aligns with the compression layout (`segmentby='symbol, granularity'`), which was the root cause of the timeout for large universes like NASDAQ or Technology globally.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gertjan/bodega#19
No description provided.