Skip to content

fix(dir): increase db connection pool - #1850

Merged
csirmazbendeguz merged 1 commit into
mainfrom
fix/increase-db-connection-pool
Jul 20, 2026
Merged

csirmazbendeguz merged 1 commit into
mainfrom
fix/increase-db-connection-pool

Conversation

@csirmazbendeguz

@csirmazbendeguz csirmazbendeguz commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

We're seeing slow queries reported by GORM in the reconciler logs:

2026/07/20 12:28:00 /build/server/database/gorm/scan.go:71 SLOW SQL >= 200ms
[283.626ms] [rows:19] SELECT * FROM "records" WHERE NOT EXISTS (
			SELECT 1 FROM scan_reports sr
			WHERE sr.record_cid = records.record_cid
			AND sr.updated_at >= '2026-07-13 12:28:00.641'

I confirmed the queries are not actually slow. I checked the queries with EXPLAIN ANALYZE and they are less than 1 milisecond (we don't have a lot of data)

I noticed the "slow" query is always the first query in the task. So I have good reason to believe they're slow because they're not re-using connections from the connection pool efficiently

This PR increases the connection pool - it will keep 10 connections warm even if they're idle (it was 2 by default). This should help with query execution times and reduce noise in the logs about slow queries

Signed-off-by: Bendegúz Csirmaz <[email protected]>
@github-actions github-actions Bot added the size/XS Denotes a PR that changes 0-49 lines label Jul 20, 2026
@csirmazbendeguz
csirmazbendeguz marked this pull request as ready for review July 20, 2026 12:43
@csirmazbendeguz
csirmazbendeguz requested a review from a team as a code owner July 20, 2026 12:43
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/database/database.go 42.9% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@csirmazbendeguz
csirmazbendeguz merged commit 74932b8 into main Jul 20, 2026
52 checks passed
@csirmazbendeguz
csirmazbendeguz deleted the fix/increase-db-connection-pool branch July 20, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-49 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants