'How does CriteriaQuery isNull slow down hibernate query?

What makes this query perform differently?

CriteriaBuilder builder;
CriteriaQuery criteria;
Root root;

criteria.where(builder.anyOtherCondition()); // runs at a reasonable speed
criteria.where(builder.isNull(root.get("name"))); // takes years

It's as though hibernate is fetching all the data in the database.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source