Dennis Volodomanov <denn...@conceiva.com>
wrote:
> I was wondering whether the SQLite parser will parse out redundant
> conditions out of an SQL statement or will it process them as if they
> are all unique?

In my experience, SQLite doesn't eliminate such redundant clauses, nor 
remove trivial conditions (like 1=1 or 1 != 0), nor shortcircuit logical 
operations, nor hoist common subexpressions (those that don't depend on 
the current row) out of the loop. An expression is translated into VDBE 
program in a very literal manner.

> I'm building dynamic SQL statements and sometimes I can't avoid
> (well, without re-working a lot of code) things like:
>
> SELECT * FROM TABLEA WHERE COLUMNA=1 AND COLUMNA=1 AND COLUMNA=1 AND
> ( COLUMNB=2 OR COLUMNC=3 )
>
> Does it hurt performance having 3 COLUMNA statements like that in any
> way?

I suspect that any inefficiency introduced by that will be immeasurably 
small. But, if in doubt, test it.

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to