But just because you have 100 values in no way indicates how many rows
will be returned. And I personally know of no optimizers that make
such an assumption; its a totally worthless assumption.
Nor is this "lack of de-dupping" any real issue that that I can think
of.
On Thu 17 May 2012 07:16:06 AM CDT, Guillaume Smet wrote:
Hi Steve,
On the list again, my bad...
On Thu, May 17, 2012 at 1:07 PM, Steve Ebersole<steve(a)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.
--
steve(a)hibernate.org
http://hibernate.org