On Oct 13, 2011, at 10:57 PM, Fabian wrote:

> Thank you very much! This approach solved the problem. However, in my
> situation I need to select a lot more columns than just 'id' from
> 'mail_header',

Feel free to select all the relevant columns from the inner query.

> and when I look at the resulting query it appears it is
> selecting all those columns twice.

Well, if you are explicit, you are specifying them twice, once in the inner 
query, and once at the top level. If that bothers you, you could use '*' in the 
inner part. Even though this is not really advisable. Better to be explicit, at 
the cost of a bit  more verbosity.

> Would it be smart to change the query so that the inner loop only selects
> mail_header.id, and adding a third join that fetches the extra columns from
> 'mail_header'?

No, that would defeat the purpose of the exercise, which is to minimize IO.

> Or would the performance penalty from adding a third join
> out-weight the advantage of selecting less columns in the inner loop?

Exactly.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to