[sqlite] Using a view is slower than using the query that comprises the view?

2006-12-16 Thread Brodie Thiesfield
Hi, In my database I find that the explain program for the view (114 statements) is much longer than direct query that comprises the view (89) and almost twice as long as doing the 2 separate queries that make up the union in the view (39 + 30 = 69). To explain more clearly what I mean, if I

Re: [sqlite] Using a view is slower than using the query that comprises the view?

2006-12-16 Thread Joe Wilson
A view is basically just a SELECT on a subquery. These two queries are functionally equivalent: SELECT * from va; SELECT * from (SELECT a, b, 0 AS c FROM ta UNION SELECT a, b, 1 FROM tb); SELECTs on subqueries (or views) containing UNION or INTERSECT or EXCEPT can be slow.