On 7/20/2013 3:29 PM, E.Pasma wrote:
Op 20 jul 2013, om 16:13 heeft Igor Tandetnik het volgende geschreven:
select id, a, b, a/b as c from (
SELECT
id,
(SELECT [very complex subselect here, that uses categories.id as
input]) AS
a,
(SELECT [another very complex subselect here, that uses categories.id as
input]) AS b
FROM categories
)
ORDER BY c;

Hi, in my opinion there is nothing funky about this query and I hope my
colleagues agree. However it can be slower than strictly needed. I
experienced that the "very complex subqueries" are evaluated each time
again when referenced from the outer query.

My experience is different. The results of the inner query are saved into an ephemeral table, which is then sorted, and iterated over by the outer query.
--
Igor Tandetnik

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

Reply via email to