Subject Re: [ib-support] need help on query optimisation
Author Rick Fincher
----- Original Message -----

Please forgive my ignorance, but what is a plan? What constitutes a change
in it?

Thanks,

Rick

> Hi Ben!
>
> ...
> >It is taking a lot of time. But if I remove the last line it is lightning
> >fast. I can't go
> >without that last line if I need to select only a company's product.
> ...
>
> When Ben Johnson says something is lightening fast, it certainly is
> extremely fast (sorry, couldn't resist). What really matters to help is
> your plan, which you do not quote. Still, with your information about
> lightening fast, it is easy to solve. Simply add a bit to that line:
>
> AND ( ( products.company_id = :dCID ) OR 4=2)
>
> The reason this should work is because it has to be a change in the plan
> that makes the query crawl. Introducing the OR bit prevents the optimizer
> from doing this change, and anything always evaluating to false will do (I
> chose 4=2 simply because of a soccer result the other day).
>
> Set