Java Performance and operations

Connection pools, pagination and the queries that only fail at scale. Most of this is invisible until the data grows.

3 concepts · 8 interview questions

What this topic covers

Every concept in performance and operations, and the questions each one gets asked as. Where a question links, it has a full write-up.

Connection pooling

Connections are expensive to create, so a pool reuses them — and the right pool size is far smaller than people expect.

  • How do you size a database connection pool?
  • What happens when the pool is exhausted?
  • Why does moving to virtual threads make pool sizing more urgent?

Pagination

OFFSET makes the database read and discard every skipped row, so page 1000 costs a thousand times page 1.

  • Why does OFFSET pagination get slower on later pages?
  • What is keyset pagination, and what does it give up?

Diagnosing a slow query

Find it in the slow log, read its plan, check the statistics, and only then consider an index.

  • A query is slow in production but fast locally. Why?
  • How do you find the queries worth optimising?
  • Is SELECT * ever acceptable?

More in Databases and persistence

See the whole reference map →