| Ko

Overcoming RAM Limits with zram Memory Compression

ZRAM Concept and Principles ZRAM (formerly known as compcache) is a memory compression technology provided by the Linux kernel that creates a virtual block device by compressing a portion of RAM. This technology was first developed by Nitin Gupta in 2009 and officially integrated into the Linux kernel from version 3.14. It has been widely used ever since. The core idea of ZRAM is to utilize compressed RAM as swap space instead of disk-based swap, effectively reducing memory usage without the overhead of disk I/O operations. This approach significantly improves system performance, especially in memory-constrained environments. ...

May 2, 2025 · 6 min · 1100 words · In-Jun

Understanding the JPA N+1 Query Problem

What is the N+1 Problem? The N+1 problem is a common performance issue in Object-Relational Mapping (ORM) where N additional queries are executed when retrieving associated entities. As a result, the total number of queries becomes N+1. When the number of queries increases, database communication multiplies, network round-trip time grows, and there is a risk of database connection pool exhaustion, which can significantly degrade performance. History and Background of the N+1 Problem The N+1 problem emerged alongside ORM frameworks and is particularly common when using Lazy Loading strategies in Hibernate and JPA. ORM frameworks adopt lazy loading as the default strategy to handle data in an object-oriented manner by deferring the loading of associated entities until needed. This approach has advantages such as preventing unnecessary data loading and improving initial loading speed. However, when developers access associated entities inside loops without recognizing the relationships, individual queries are executed for each entity, causing the N+1 problem. This has remained a critical performance issue that developers must be aware of from the early versions of Hibernate to the present. ...

June 8, 2024 · 7 min · 1373 words · In-Jun

JPA Lazy Loading vs Eager Loading Performance

History and Necessity of Loading Strategies ORM (Object-Relational Mapping) frameworks emerged to solve the impedance mismatch between object-oriented programming and relational databases. During this process, how to efficiently load entities with associations became a critical challenge. Early ORM implementations used immediate loading for all associated entities, which caused performance degradation by loading unnecessary data into memory. Hibernate introduced a proxy-based lazy loading mechanism to solve this problem. Hibernate has continuously improved loading strategies since its initial release in 2001. While early versions only supported simple lazy loading, later versions added various optimization techniques such as fetch join, batch fetching, and subselect fetching. These features were included in the JPA (Java Persistence API) 1.0 standard when it was released in 2006. Through JPA 2.0 (2009) and JPA 2.1 (2013), declarative fetch strategies like @EntityGraph were added, enabling more sophisticated control over associated entity loading. Today, the JPA standard and Hibernate implementation continue to evolve together, providing developers with various options. ...

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