Subject | RE: [Firebird-Java] PreparedStatement with LIKE ? extremly slow |
---|---|
Author | Rick Debay |
Post date | 2007-02-06T16:04:03Z |
Or the program could use the appropriate SQL depending on if it was
going to use a wild-card or not.
-----Original Message-----
From: Firebird-Java@yahoogroups.com
[mailto:Firebird-Java@yahoogroups.com] On Behalf Of Roman Rokytskyy
Sent: Tuesday, February 06, 2007 4:45 AM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] PreparedStatement with LIKE ? extremly slow
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
Yahoo! Groups Links
Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.
going to use a wild-card or not.
-----Original Message-----
From: Firebird-Java@yahoogroups.com
[mailto:Firebird-Java@yahoogroups.com] On Behalf Of Roman Rokytskyy
Sent: Tuesday, February 06, 2007 4:45 AM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] PreparedStatement with LIKE ? extremly slow
> 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
Yahoo! Groups Links
Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.