[hibernate-dev] Memory consumption

Guillaume Smet guillaume.smet at gmail.com
Thu May 17 08:16:06 EDT 2012


Hi Steve,

On the list again, my bad...

On Thu, May 17, 2012 at 1:07 PM, Steve Ebersole <steve at hibernate.org> wrote:
> I am not following what you are saying about "reusing keys" and optimizers.
>  Nor how it might lead to bad execution plans.  Can you elaborate on your
> thoughts here?

If you have a lot of (OR primaryKey=value) clauses with the same
value, if the optimizer doesn't deduplicate the clauses, the
statistics used by the planner to build the query plan might be wrong
and lead to bad query plans.

At least some of the optimizers out there don't remove identical
values as it's a lot of cycles usually wasted for nothing as nobody
writes query like that.

Simplified example: if you have 100 (OR primaryKey=1) clauses, the
planner might consider that you'll have 100 values returned which is
plain wrong in this case. It's not important if the query is simple
and you don't have a lot of joins but if you're in the case of a
complex object hierarchy with a lot of left joins, it might lead to
really bad execution plans.

-- 
Guillaume



More information about the hibernate-dev mailing list