Re: Prepared SQL Statements and Performance
Posted in 1996
In answer to :
"The Informix SQL reference manuals state that using a prepared SQL statement
together with an
Execute statement makes the SQL more efficient. If this is true, then which
example is more
efficient:
declare cursor1 cursor for
select col1, col2, col3
from tablea
where col1 = col5
or
let l_SQL = "select col1, col2, col3 ",
"from tablea ",
"where col1 = col5"
prepare SQL_stmt from l_SQL
declare cursor1 cursor for SQL_stmt
Note that I did not use an execute in this example. Which of the aboove
examples yields the best
performance and why?
"
------------------------------------------------------------------------------
------------------------------------------------
My understanding is that if you execute the prepared statement more than
once, then it is worthwhile.
If you are using it to just declare a cursor once, then it doesn't make any
difference. There isn't an execute associated with a select. The way you
are doing it can be compared to the execute statement, as you are still
effectively executing prepared code.
See any answers to my posting "Speeding up reports, general processing in
4GL?", as they may throw more light on the subject for both of us!!