Many Spring Boot performance incidents blamed on the database start in the application: connection pools that run dry, transactions held open by slow clients, and queries that use an index but still read millions of rows. These articles show the measurements behind each diagnosis.
All articles on this page are also collected in a Medium list you can save and follow.
Start here
- Spring Boot Didn’t Slow Down — It Collapsed at 300 Users — a load test where the HikariCP pool collapsed at 300 users
- PostgreSQL Used the Index. The Query Still Read 8.7 Million Rows. — an index scan that still read 8.7 million rows
- Our Server Was Healthy. Our Connection Pool Was Exhausted. — connection pool exhaustion behind healthy-looking servers
Queries and indexes
- PostgreSQL Was Not Slow. Our Index Was Useless. — an index the planner could not use
- PostgreSQL Used the Index. The Query Still Read 8.7 Million Rows. — index scans that still read too many rows
- JPA Failed When Data Reached 10 Million Rows — JPA behaviour at 10 million rows
Connections and transactions
- Our Server Was Healthy. Our Connection Pool Was Exhausted. — HikariCP pool exhaustion
- Spring Boot Didn’t Slow Down — It Collapsed at 300 Users — pool sizing versus request threads under load
- When a CSV Download Controls Your PostgreSQL Transaction — a streaming download that held a transaction open
- The Database Was Fine. The Spring Boot API Was Still Slow. — API latency outside the database
- PostgreSQL Was Fast. Our Spring Boot API Still Ran Out of Memory! — memory exhaustion from large result sets
- Kafka Lag Hid a Database Bottleneck — a database bottleneck surfacing as consumer lag
Setup and stored procedures
- PostgreSQL on Docker Failed Without Durable Volumes — durable volumes for PostgreSQL in Docker
- PostgreSQL Procedures Failed Under Real Data — procedures under real data volumes
- Spring Boot PostgreSQL Procedures Failed in Production — calling procedures from Spring Boot
- Spring Boot 3 CRUD Operations Guide with PostgreSQL — CRUD operations with Spring Boot 3 and PostgreSQL
Also on bytzecho.com
Versions of these articles on this site, with extended code and notes.
- PostgreSQL Used the Index. It Still Processed Millions of Rows. — an index scan that still processed millions of rows.
- Why Slow CSV Downloads Can Keep PostgreSQL Transactions Open in Spring Boot — streaming downloads inside transactions.
- API Slow? Database Fine — Real Performance Case Study — a reminder that database blame can be premature.
- JPA vs JDBC Performance — 10M Rows (PostgreSQL) — what changes when data volume makes abstraction cost visible.
- Kafka Lag vs PostgreSQL Writes: What Slowed the Consumer Down — when consumer throughput depends on database write behavior.
- Spring Boot CRUD Operations Guide with PostgreSQL — baseline CRUD patterns for Spring Boot applications.
- Call Stored Procedures in PostgreSQL with Spring Boot 3 — stored procedure integration when logic moves closer to data.
- Create Stored Procedures and Functions in PostgreSQL — PostgreSQL-side function and procedure design basics.
- How to Set Up PostgreSQL Database Server with Docker — local infrastructure for database experiments.
- JobRunr with Spring Boot: In-Memory Jobs vs Database Persistence — background job persistence trade-offs.
- Spring Boot Quartz Scheduler Guide with Examples — scheduled work and persistence considerations.
Frequently asked questions
Why is a PostgreSQL query slow even though it uses an index?
An index scan can still read millions of rows when the indexed condition is not selective or the remaining filters are applied after the scan. Run EXPLAIN (ANALYZE, BUFFERS) and compare rows read with rows returned. See PostgreSQL Used the Index. The Query Still Read 8.7 Million Rows.
What causes HikariCP connection pool exhaustion in Spring Boot?
Requests hold connections longer than the pool can serve them: long transactions, slow calls made inside a transaction, or more concurrent requests than connections. HikariCP’s default maximum pool size is 10, and waiting requests fail once connectionTimeout (30 seconds by default) passes.
Why can a CSV download keep a database transaction open?
If the controller streams query results to the client inside a transaction, the transaction stays open until the slowest client finishes downloading. Read the data first, or stream outside the transaction with a bounded fetch size.
New articles are published on Medium first. Subscribe to the newsletter to get production lessons by email.