Suppose

TblB has primary key ColB and contains a column ColBX
TblC has primary key ColC and contains a column ColCX
TblD has primary key ColD and contains a column ColDX

TblA has primary key ColA and also contains columns ColB, ColC and ColD

(i.e. TblB, TblC and TblD are effectively lookup tables for TblA).

If I run the following query

explain
select ColA from TblA
left join TblB using (ColB)
left join TblC using (ColC)
left join TblD using (ColD)
where ColBX=?;

there will be no trace of TblC or TblD as they're redundant.

If i run the following query

explain
select ColA from TblA
left join TblB using (ColB)
left join TblC using (ColC)
left join TblD using (ColD)
where ColCX=?;

there will be no trace of TblD as it's redundant but what I need explaining is 
why is TblB included in the explain.

I'm guessing that the sqlite query optimiser finds it easy to ignore trailing 
redundant tables but checking for other redundant tables is too expensive. Is 
that the case or am I missing something and the inclusion of TblB is necessary 
to get the correct result?
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to