in reply to prepare statement within DBI

I could combine the two sql statements into one statement

Well, you could with a union:

select 't1', count(*) from t1 union select 't2', count(*) from t2

... but you must add something to each select (here, the name of the table as a string) to what is returned in order to guarantee that you can determine which count(*) corresponds to which table. You never know which order they'll come back in. But now you have just about as much make-work code to pick the apart the result set and get what you want.

My advice would be to encapsulate it in a sub and use cached prepares.

my $t1_count = table_row_count( $dbh, 'table1' ); my $t2_count = table_row_count( $dbh, 'table2' ); sub table_row_count { my $db = shift; my $table = shift; my $sth = $db->prepare_cached( "select count(*) from $table" ); $sth->execute(); return $sth->fetchrow_array; }

Error checking is left as an exercise to the reader.

- another intruder with the mooring of the heat of the Perl