Op 20 jul 2013, om 16:13 heeft Igor Tandetnik het volgende geschreven:

On 7/20/2013 9:54 AM, Mikael wrote:
So again,

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,
a / b AS c
FROM categories
ORDER BY c;

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;

--
Igor Tandetnik

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. That is three times here:
- select a, b
- select a / b as c
- order by c
I like to make myself more clear in a seperate mail and work out a reproducible case because I hope this could be improved in the optimizer.
Thanks, EPasma (sqlite version 3.7.15)

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

Reply via email to