| Ko

zram compressed swap

When memory runs low, Linux pushes rarely used pages out to swap. The problem is that swap usually lives on disk. The moment disk swap gets busy, the system noticeably stutters. zram puts that swap in compressed RAM instead of on disk: rather than writing pages to disk, it compresses and keeps them in RAM. The trade is simple. You spend a little extra CPU compressing and decompressing, and in return you turn disk I/O into RAM access. Text-like data typically compresses 2:1 to 4:1, so you get back the physical RAM that pages would have consumed, at less than half the cost. ...

May 2, 2025 · 4 min · 724 words · In-Jun

The JPA N+1 query problem

You fetch a list of members once, then look at the SQL log and find 101 SELECT lines. That’s the N+1 problem. One initial query to fetch the entities, plus N more, one each time you touch the association, for a total of N+1. The signal here isn’t an estimated millisecond count; it’s the number of queries in the log. How one becomes 101 Say Member references Team with lazy loading (FetchType.LAZY). You fetch 100 members and print each one’s team name in a loop. ...

June 8, 2024 · 5 min · 885 words · In-Jun
[email protected]