Subject | Re: [ib-support] search conditions in OUTER JOIN vs WHERE |
---|---|
Author | Paul Reeves |
Post date | 2002-11-13T16:25:24Z |
Marco Bommeljé wrote:
AND e.emp_no IS NULL
in the JOIN clause the optimizer seems clever enough to completely
ignore the employee table. Despite producing this plan
PLAN JOIN (E NATURAL,J INDEX (RDB$PRIMARY2))
it would appear that employee is read neither sequentially, nor via an
index. This is certainly an interesting anomaly.
research it, if necessary).
optimizer for initiative! It would certainly speed up a query if the
employee table was large and the job table was small.
Paul
--
Paul Reeves
http://www.ibphoenix.com
Supporting users of Firebird and InterBase
> Employee base table. This shows more clearly when the "e.emp_no ISBy specifying
> NULL" predicate is added to the OUTER JOIN's search condition:
>
> FROM job j LEFT OUTER JOIN employee e
> ON e.job_code = j.job_code
> AND e.job_grade = j.job_grade
> AND e.job_country = j.job_country
> AND e.emp_no IS NULL ;
>
> The query result table suggests that in this case e.emp_no values are
> read from the base table.
>
AND e.emp_no IS NULL
in the JOIN clause the optimizer seems clever enough to completely
ignore the employee table. Despite producing this plan
PLAN JOIN (E NATURAL,J INDEX (RDB$PRIMARY2))
it would appear that employee is read neither sequentially, nor via an
index. This is certainly an interesting anomaly.
> * Is this behaviour documented anywhere?I shall bow to the wisdom of others on these two questions (or go and
> * Does the SQL standards say anything on this subject?
research it, if necessary).
> * How can I best explain this to students in my Ib/Fb courses?Skip lightly past it? Compare this with another database implementation?
> * Is this a feature or a bug?That rather depends. It is probably a bug, but top marks to the
optimizer for initiative! It would certainly speed up a query if the
employee table was large and the job table was small.
> * Or is it a case for the Firebird documentation project?Or the Firebird Gotcha project?
>
Paul
--
Paul Reeves
http://www.ibphoenix.com
Supporting users of Firebird and InterBase