> It would be far simpler to fix your query generator to not emit the
> useless "0 or".
I'm using ODBC and npgsql drivers. Those drivers replace parameters
automatically.
E.q. for npgsql or every other ADO .NET I can write
"SELECT * FROM (:param1 OR (x IN SELECT y FROM z) AND :param2) ...
etc.
param1, param2, ..., paramn etc. are entered by user and passed to driver as
parameters.
Proposed solution requires:
1. Stop using this type parameter replacement. Write case statements for
every possible paramn combination in application code,
total n! case statements.
or
2. Create expression parser which understands syntax for every backend
version and simplifies expression as string before passing to backend.
> Even if we made the planner deal with that, the number of cycles it
> would expend to recover from the generator's stupidity would be several
> orders of magnitude higher than the number of cycles needed to not be so
> stupid.
Proposed solution requires re-writing ODBC and npgsql and possibly every
other driver to add expression parser and constant optimization to it in
client side.
This seems to be huge work and no one dbms does not implement this.
In this case every query is processed two times. I do'nt understand how this
takes less time that processing query once in backend.
Andrus.