See https://www.sqlite.org/optoverview.html
under section 10.0 Query Flattening

Your query is:

SELECT * FROM <view> WHERE <condition>

which could be treated as

SELECT *
  FROM (view select statement)
 WHERE condition

and then flattened.  Note however that the query WILL NOT be flattened because 
of rule #2, the subselect in the FROM clause contains an aggregate ...

> -----Original Message-----
> From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org]
> On Behalf Of Jens Alfke
> Sent: Sunday, 16 October, 2016 12:17
> To: SQLite mailing list
> Subject: Re: [sqlite] Why takes the second SELECT three times as much
> time?
> 
> 
> > On Oct 16, 2016, at 4:49 AM, Luuk <luu...@gmail.com> wrote:
> >
> > Because your second query has to build the complete view before it can
> decide if a result is between the selected dates?
> 
> I didn’t think a view had a physical manifestation that had to be built; I
> thought it was just a shortcut/macro for a nested SELECT statement.
> Or is the query optimizer not able to convert the nested SELECT into the
> same form as the first query?
> 
> —Jens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



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

Reply via email to