hello, all

Given the following situation what is more efficient:

-I have 10 id numbers I want to query on numbers 1,2,3,4,5,6,7,8,9,10
respectively. However, this list is not fixed and could be any number of
ids up to 20.

-Is it faster to create a global variable with a prepared sql statement
at the begining of the mod_perl script as follows:
$sth = $dbh->prepare('SELECT name FROM table_name WHERE id = ?');
then iterate through n number of  ids later in the script for the
$sth->execute(1);

-Or is it faster to  prepare the statement each time the script is
called with the following sql statement and execute once:
$sth = $dbh->prepare('SELECT name FROM table_name WHERE id IN
(1,2,3,4,5,6....)';
$sth->execute;

Basically, A persistent sql handle with many executes VS a
non-persistent sql handle with one execute.
The dbh is cached and global for both...

thanx,
-amen

Reply via email to