Hi all,<br /> I'm composing a query from a web application of type:<br /><br /> <b>SELECT * FROM table WHERE
a_text_fieldLIKE replace_something ('%</b><b><i>a_given_string</i></b><b>%');</b><br /><br /> The function
replace_something(... ) is a stored procedure that replaces some particular characters with others.<br /> The problem
isthat I noticed that this query is inefficient... and I think that the replace_something ( ... ) function is called
foreach row of the table.<br /><br /> This observation is motivated by the fact that it takes around 30 seconds to
executeon the table (of about 25,000 rows), whereas if I execute:<br /> <b>SELECT * FROM table WHERE a_text_field
LIKE'</b><b><i>pre_processed_string</i></b><b><i></i></b><b>';</b><br /><br /> where<i> pre_processed_string</i><i>
</i>isthe result of the application of replace_something ('%<i>a_given_string</i>%') it just takes 164ms.<br /><br />
Theexecution of <br /> <b>SELECT replace_something ('%</b><b><i>a_given_string</i></b><b>%')</b><br /> takes only
14ms.<br/><br /> Summarizing, <br /> - Replace function: 14ms<br /> - SELECT query without replace function:
164ms<br/> - SELECT query with replace function: 30.000ms<br /><br /> Morever, I cannot create a stored procedure
thatprecalculate the <i>pre_processed_string </i>and executes the query, since I dinamically <br /> compose other
conditionsin the WHERE clause.<br /><br /> Any suggestion?<br /><br /> Thank you.<br /><i></i>