Why this LIMIT

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why this LIMIT

Cecil Westerhof-5
I see that in certain older queries I use:
    LIMIT  (SELECT COUNT(*) FROM TABLE)

​It looks like​ this has no use (limiting the selected records to the
number of records there are). Anyone an idea what could be a reason for
this?

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why this LIMIT

Clemens Ladisch
Cecil Westerhof wrote:
> I see that in certain older queries I use:
>     LIMIT  (SELECT COUNT(*) FROM TABLE)
>
> ​It looks like​ this has no use (limiting the selected records to the
> number of records there are). Anyone an idea what could be a reason for
> this?

Trying to put some table data into the cache?

Reading into a fixed-sized array, and protecting against concurrent
inserts (from inside the same transaction)?

Needing the LIMIT clause for some reason (disabling subquery flattening?)
but not knowing about "LIMIT -1"?


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Why this LIMIT

Cecil Westerhof-5
2018-03-11 9:49 GMT+01:00 Clemens Ladisch <[hidden email]>:

> Cecil Westerhof wrote:
> > I see that in certain older queries I use:
> >     LIMIT  (SELECT COUNT(*) FROM TABLE)
> >
> > ​It looks like​ this has no use (limiting the selected records to the
> > number of records there are). Anyone an idea what could be a reason for
> > this?
>
> Trying to put some table data into the cache?
>
> Reading into a fixed-sized array, and protecting against concurrent
> inserts (from inside the same transaction)?
>
> Needing the LIMIT clause for some reason (disabling subquery flattening?)
> but not knowing about "LIMIT -1"?
>

​None ring a bell.

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users