Subject | Re: [Firebird-Java] PreparedStatement with LIKE ? extremly slow |
---|---|
Author | Roman Rokytskyy |
Post date | 2007-02-06T09:44:56Z |
> What values should be used for 1= ? and 2 = ? ???No, it should be something like:
> '2005-0119849- 8' ???
WHERE (1 = 2 AND f_liefer_nr = '2005-0119849- 8') OR ( 2 = 2 AND
f_liefer_nr LIKE '2005-0119849- 8')
or
WHERE (1 = 1 AND f_liefer_nr = '2005-0119849- 8') OR ( 2 = 1 AND
f_liefer_nr LIKE '2005-0119849- 8')
But I guess it won't work. You should check:
SELECT * FROM my_table WHERE (1 = ? AND f_liefer_nr = ?)
UNION
SELECT * FROM my_table WHERE (2 = ? AND f_liefer_nr LIKE ?)
The first statement would not use the index in OR condition, while the
union will. The first parameters should be equal, 1 or 2, this is a
switch that switches off one or another part of the statement.
Roman