On 2018/01/04 12:36 AM, Richard Hipp wrote:
On 1/3/18, Shane Dev <devshan...@gmail.com> wrote:
sqlite> with recursive cnt(x) as (select 1 union all select x+1 from cnt)
select * from cnt where x <= 3;
[no sqlite> prompt, CPU utilization 25%]
I assume sqlite is recursively adding rows to the queue without considering
that the subsequent SELECT only needs the first 3 of them.
No, it is continuing to search for rows for which x<=3. The query
planner does not know enough algebra to figure out that that will
never happen again after the first three rows.
Not to mention that if you wait several years, depending on your
processor/compiler, the integer 64 value might wrap around and x<=3
might become true once more, producing rows again.... :)
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users