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;
... etc

What about this table:

CREATE TABLE bar(
??? id      INTEGER PRIMARY KEY,
??? foo   TEXT UNIQUE,
)

And queries like:

SELECT id FROM bar WHERE foo = ? LIMIT 1;
SELECT 1 FROM bar WHERE foo = ? LIMIT 1;
... etc


In other words, is statement builder is smart enough to render "LIMIT 1" 
suggestion useles or even noxious, 
if we take into account the fact that these are extra characters and tokens 
that parser must waste CPU cycles/RAM on?


Up until now, for some reasong unknown to me, I always took "LIMIT 1" as an 
advantage for granted.
But now, finally I want to make thing clear.

Thanks, 
Paul


Reply via email to