Considering that INTERSECT is logically nothing but a special case of
relational join (the exact opposite of cartesian product), where all
columns are involved in the join condition, you should just be able to
reuse any optimizations that exist for join, including primary/unique
keys/etc. -- Darren Duncan

> Documentation says that INTERSECT implemented with temporary tables either
> in memory or on disk. Is it always the case? The problem is that if I have
> several selects (six for example) when each produces thousands of results
> and the intersection is only hundreds the query takes about minute to
> execute. But all these selects are properly ordered to do intersection
> without extra files usage. For example I know that I can make it in my
> code
> by splitting these selects into separated prepared statements and making
> synchronous stepping outputting only if all steps have equal value(s). If
> there's no such optimization, is it possible to implement it in the sqlite
> engine? I know that having very complex query with many selects it would
> be
> a hard task to recognize such a specific case but maybe it is easier than
> it
> seems.


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

Reply via email to