>From now on I wont use "LIMIT 1" in these cases any more.
Such queries will be more readable and surely not slower.
Thank you for explanation!
Paul
5 February 2016, 14:21:35, by "Richard Hipp" :
> On 2/5/16, Paul wrote:
> >
> > Does it have any advantage or worse, a downside to have "LIMIT
Suppose we have table:
CREATE TABLE foo(
??? id??? INTEGER PRIMARY KEY,
??? bar INTEGER
)
Does it have any advantage or worse, a downside to have "LIMIT 1" in a queries
with "... WHRE id = ?;" ?
For example:
SELECT bar FROM foo WHERE id = ? LIMIT 1;
SELECT 1 FROM foo WHERE id = ? LIMIT 1;
...
Paul wrote:
> CREATE TABLE bar(
> id INTEGER PRIMARY KEY,
> foo TEXT UNIQUE,
> )
>
> SELECT 1 FROM bar WHERE foo = ? LIMIT 1;
>
> is statement builder is smart enough to render "LIMIT 1" suggestion useles
No, the LIMIT 1 logic is never removed.
> if we take into account the fact th
On 2/5/16, Paul wrote:
>
> Does it have any advantage or worse, a downside to have "LIMIT 1" in a
> queries with "... WHRE id = ?;" ?
> For example:
>
> SELECT bar FROM foo WHERE id = ? LIMIT 1;
> SELECT 1 FROM foo WHERE id = ? LIMIT 1;
> ... etc
>
When "id" is a UNIQUE column (or an INTEGER PRIM
4 matches
Mail list logo