Dave Blake wrote:
> Is there anything I can do to get the optimiser to perform 1) with the same
> efficiency as 2)?

See point 3 of <http://www.sqlite.org/optoverview.html#flattening>; the
optimizer has problems when you use a subquery (i.e., a view) at the
right side of a left join.

If you really want to keep the view, you could replace the outer join
with an inner join, and add the non-matching rows separately:

SELECT A.*, view.* FROM A JOIN view ON ... WHERE ...
UNION ALL
SELECT A.*, NULL FROM A WHERE ... AND id NOT IN (SELECT A_id FROM view);

Whether this is better than breaking up the view is something you have
to decide yourself.


Regards,
Clemens

Reply via email to