The best way to use the JPA OneToOne optional attribute

Introduction In this article, we are going to see what is the best way we can use OneToOne optional attribute so that we can avoid N+1 query issues. One-To-One table relationship As I explained in this article, in a one-to-one table relationship, the parent and the child tables s … | Continue reading


@vladmihalcea.com | 7 days ago

How to calculate percentiles with SQL PERCENTILE_CONT

Introduction In this article, we are going to investigate how to calculate percentiles with the SQL PERCENTILE_CONT function. Domain Model Let’s consider we have the following quotes table that holds the historical price values of various stocks and indexes: The quotes table is p … | Continue reading


@vladmihalcea.com | 13 days ago

PostgreSQL FOR UPDATE vs FOR NO KEY UPDATE

Introduction In this article, we are going to investigate the difference between the PostgreSQL FOR UPDATE and FOR NO KEY UPDATE when locking a parent record and inserting a child row. Domain Model To see the difference between the PostgreSQL FOR UPDATE and FOR NO KEY UPDATE lock … | Continue reading


@vladmihalcea.com | 21 days ago

High-Performance Java Persistence Newsletter, Issue 61

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java. Articles The pick of this week … | Continue reading


@vladmihalcea.com | 28 days ago

PostgreSQL Heap-Only-Tuple or HOT Update Optimization

Introduction In this article, we are going to analyze how PostgreSQL Heap-Only-Tuple or HOT Update optimization works, and why you should avoid indexing columns that change very frequently. PostgreSQL Tables and Indexes Unlike SQL Server or MySQL, which store table records in a C … | Continue reading


@vladmihalcea.com | 1 month ago

PostgreSQL Index Types

Introduction In this article, we are going to analyze the PostgreSQL Index Types so that we can understand when to choose one index type over the other. When using a relational database system, indexing is a very important topic because it can help you speed up your SQL queries b … | Continue reading


@vladmihalcea.com | 1 month ago

High-Performance Java Persistence Newsletter, Issue 60

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java. Articles The pick of this week … | Continue reading


@vladmihalcea.com | 1 month ago

How to map the OffsetDateTime ZoneOffset with Hibernate TimeZoneColumn

Introduction In this article, we are going to see how we can map the OffsetDateTime ZoneOffset with the Hibernate TimeZoneColumn annotation. As I explained in this article, by default, Hibernate doesn’t store the time-zone offset of an OffsetDateTime entity attribute in a separat … | Continue reading


@vladmihalcea.com | 2 months ago

How to use Java Records with Spring Data JPA

Introduction In this article, we are going to see how we can use Java Records with Spring Data JPA Repositories. As I already explained, Java Records cannot be used as JPA entities since the Records are immutable, and JPA requires the entity class to have a default constructor an … | Continue reading


@vladmihalcea.com | 2 months ago

PostgreSQL Performance Tuning Settings

Introduction In this article, we are going to explore various PostgreSQL performance tuning settings that you might want to configure since the default values are not suitable for a QA or production environment. As explained in this PostgreSQL wiki page, the default PostgreSQL co … | Continue reading


@vladmihalcea.com | 2 months ago

Hibernate StatelessSession JDBC Batching

Introduction In this article, we are going to see how we can use the Hibernate StatelessSession in order to enable JDBC Batching for INSERT, UPDATE, and DELETE statements. While the StatelessSession has been available for more than 20 years, until Hibernate 6, its usefulness was … | Continue reading


@vladmihalcea.com | 2 months ago

High-Performance Java Persistence Newsletter, Issue 59

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java. Articles The pick of this week … | Continue reading


@vladmihalcea.com | 3 months ago

The race condition that led to bankruptcy

Learn how a race condition led to the bankruptcy of Flexcoin in 2014 after hackers stole all the available funds. | Continue reading


@vladmihalcea.com | 1 year ago

How to create a tech startup – a real-life story

Learn how you can create a tech startup. This is the real-life story of how I created RevoGain. | Continue reading


@vladmihalcea.com | 2 years ago

My Eight year journey of blogging about SQL and Java

Eight years and counting! It was September 2013, and I had always wanted to start a blog but had never found the motivation to do it. If you keep on waiting for the right time to do something, that day might never come. Either you start right away, or you just keep on lying to yo … | Continue reading


@vladmihalcea.com | 2 years ago

60 years of COBOL – past, present, and future

60 years of COBOL, and, most likely, it's here for the future. This article is an interview with Adrian Tot about the state of COBOL. | Continue reading


@vladmihalcea.com | 3 years ago

The Anatomy of Connection Pooling

Introduction All projects I’ve been working on have used database connection pooling and that’s for very good reasons. Sometimes we might forget why we are employing one design pattern or a particular technology, so it’s worth stepping back and reason on it. Every technology or t … | Continue reading


@vladmihalcea.com | 3 years ago

How Does the 2PL (Two-Phase Locking) Algorithm Work

Learn what the 2PL (Two-Phase Locking) algorithm works and how it can guarantee data integrity strict serializability in a relational database system. | Continue reading


@vladmihalcea.com | 4 years ago

14 High-Performance Java Persistence Tips

(Last Updated On: June 6, 2018)Introduction A high-performance data access layer requires a lot of knowledge about database internals, JDBC, JPA, Hibernate, and this post summarizes some of the most important techniques you can use to optimize your enterprise application. 1. SQL … | Continue reading


@vladmihalcea.com | 5 years ago

How Does MVCC (Multi-Version Concurrency Control) Work

(Last Updated On: January 4, 2018)Introduction In Concurrency Control theory, there are two ways you can deal with conflicts: You can avoid them, by employing a pessimistic locking mechanism (e.g. Read/Write locks, Two-Phase Locking) You can allow conflicts to occur, but you need … | Continue reading


@vladmihalcea.com | 5 years ago

9 High-Performance Tips When Using PostgreSQL with JPA and Hibernate

If you are struggling with data access performance issues, then you should definitely check out these PostgreSQL performance tuning tips. | Continue reading


@vladmihalcea.com | 5 years ago

A beginner’s guide to database multitenancy

Learn various multitetancy strategies when using a relational database system like catalog, schema or table-based tenant isolation patterns. | Continue reading


@vladmihalcea.com | 5 years ago

How to Use PrePersist and PreUpdate on Embeddable with JPA and Hibernate

Learn how to use the JPA @PrePersist and @PreUpdate entity event listeners on Embeddable types with Hibernate ORM 5.2.17 | Continue reading


@vladmihalcea.com | 5 years ago