Skip to content

Task: Create Batch Job to Run Aggregation Query and Update hit_count recordsΒ #357

Open

Description

@nelsonic

As noted in #355 the aggregation query (SELECT COUNT(*) FROM hits WHERE repo_id = 123) πŸ’­
takes 2 MINUTES on a table with 30 Million Rows. ⏳
And is the reason the request/query time-out and crashes the server! πŸ’”

So we're implementing hit_count πŸ†•
which is just an integer counter 1️⃣
to return millisecond responses again. 🏎️ 🏁 πŸŽ‰

The problem is that we are temporarily ignoring the historical data in the hits table ... πŸ™„
But the data is not "lost" it's just in stasis. πŸ’­
So ...

Todo

  • Create a batch job to go through the hit_count table
    and update count to reflect the aggregate from hits. πŸ§‘β€πŸ’»
  • This must be done gradually to avoid crashing the server again. βš–οΈ
  • Once all records are updated, we can sunset this data migration script. πŸŒ†
  • I expect writing the script to take around T1h and running it to take T1w ⏳
    (Running the script once per minute to process a single record. 1440 runs per day. 10,000/week)

Will work on this immediately after I have #355 working.

Activity

  1. self-assigned this
    on Jul 13, 2026
  2. added
    elixir
    on Jul 13, 2026
  3. added theissue type on Jul 13, 2026
  4. moved this to More ToDo ThanCanEver Be Done in Nelson's Liston Jul 13, 2026
  5. nelsonic commented on Jul 13, 2026

    @nelsonic
    MemberAuthor

    A Practical Guide to Elixir’s Task Module β€” Let’s create a Cron Job: https://medium.com/@Vickris/a-practical-guide-to-elixirs-task-module-let-s-create-a-cron-job-4c6afe74b846

  6. nelsonic commented on Jul 14, 2026

    @nelsonic
    MemberAuthor

    PR: #360 πŸ§‘β€πŸ’» ⏳

  7. nelsonic commented on Jul 14, 2026

    @nelsonic
    MemberAuthor

    Using quantum https://github.com/quantum-elixir/quantum-core for this task as it has all the scaffold for what we need.
    It's a temporary dependency and will be removed once all data is migrated. βœ…

  8. added a commit that references this issue on Jul 14, 2026
  9. asntc commented on Jul 15, 2026

    @asntc
    Member

    The quantum cron job works fine. The issue is duplicate entries in the DB: #365

  10. nelsonic commented on Jul 15, 2026

    @nelsonic
    MemberAuthor

    Yeah, we need to figure this out tomorrow ... πŸ§‘β€πŸ’» 🀞

  11. nelsonic commented on Jul 15, 2026

    @nelsonic
    MemberAuthor

    GOTO: #366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

T1helixirenhancementhelp wantedpriority-2technical

Type

Projects

  • Status
    More ToDo ThanCanEver Be Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions