Skip to content

fix: batch insert + heap-based rate limiter eviction#141

Merged
poyrazK merged 1 commit intomainfrom
fix/performance-n-plus-one-and-rate-limiter
May 6, 2026
Merged

fix: batch insert + heap-based rate limiter eviction#141
poyrazK merged 1 commit intomainfrom
fix/performance-n-plus-one-and-rate-limiter

Conversation

@poyrazK
Copy link
Copy Markdown
Owner

@poyrazK poyrazK commented May 6, 2026

Summary

Changes

  • internal/adapters/repository/postgres.go: Batch insert using multi-row VALUES with scalar args
  • internal/dns/server/ratelimit.go: Min-heap keyed by last timestamp with heap.Fix on update, heap.Remove on Cleanup()

Test plan

  • go build ./...
  • go test ./internal/adapters/repository/... ./internal/dns/server/... -timeout 60s -race

Related issues

- #83: Replace row-by-row record inserts with multi-row VALUES batch insert
- #72: Replace O(n) bounded scan with O(log n) heap-based eviction
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@poyrazK has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 36 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21d70b1e-bacc-40d0-ac81-6920b3275fca

📥 Commits

Reviewing files that changed from the base of the PR and between 35810d9 and 47f7904.

📒 Files selected for processing (2)
  • internal/adapters/repository/postgres.go
  • internal/dns/server/ratelimit.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/performance-n-plus-one-and-rate-limiter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Owner Author

@poyrazK poyrazK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay to merge

@poyrazK poyrazK merged commit 82c0d02 into main May 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

N+1 query: CreateZoneWithRecords inserts records row-by-row Rate limiter evictOldestBucket() causes O(n) pause under high bucket count

1 participant