[sqlite] Question about LIMIT 1 fitness on lookups by unique index

2016-02-05 Thread Paul
>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

[sqlite] Question about LIMIT 1 fitness on lookups by unique index

2016-02-05 Thread Paul
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; ...

[sqlite] Question about LIMIT 1 fitness on lookups by unique index

2016-02-05 Thread Clemens Ladisch
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

[sqlite] Question about LIMIT 1 fitness on lookups by unique index

2016-02-05 Thread Richard Hipp
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