Replace per-row PitchingCardRatings lookup with batched fetch in pitcher sort #19

Closed
opened 2026-02-20 06:52:49 +00:00 by cal · 1 comment
Owner

`app/routers_v2/teams.py:600-614` and `679-693`. `get_total_ops` called via `DataFrame.apply` executes two queries per row. 30 rows = 60 queries.

Priority: medium

\`app/routers_v2/teams.py:600-614\` and \`679-693\`. \`get_total_ops\` called via \`DataFrame.apply\` executes two queries per row. 30 rows = 60 queries. **Priority**: medium
cal added the
performance
label 2026-02-20 06:52:49 +00:00
cal added the
ai-working
label 2026-03-03 23:01:09 +00:00
cal removed the
ai-working
label 2026-03-03 23:03:53 +00:00
Author
Owner

Fixed in PR #44: #44

Both sort_pitchers and sort_starters now fetch all PitchingCardRatings for the batch of card IDs in a single query, building a (pitchingcard_id, vs_hand) → rating dict. The apply closure does O(1) dict lookups instead of 2 queries per row, reducing 2N queries to 1.

Fixed in PR #44: https://git.manticorum.com/cal/paper-dynasty-database/pulls/44 Both `sort_pitchers` and `sort_starters` now fetch all `PitchingCardRatings` for the batch of card IDs in a single query, building a `(pitchingcard_id, vs_hand) → rating` dict. The `apply` closure does O(1) dict lookups instead of 2 queries per row, reducing 2N queries to 1.
cal added the
ai-pr-opened
label 2026-03-03 23:04:02 +00:00
cal closed this issue 2026-03-10 18:26:24 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
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: cal/paper-dynasty-database#19
No description provided.