At 04:28 PM 4/3/02 -0500, Kevin Old wrote:
>Hello all,
>
>I am a consultant brought in to manage and restructure some Perl scripts that
>were written some time ago. The programmer at that time was using the
>following code to do a query from within a CGI page.
>
> ${query} = "SELECT ccyymmddhh FROM inventory ORDER BY ccyymmddhh ;" ;
> open( INPUT, "echo \"${query}\" |
>/usr/local/mysql/bin/mysql -A -q -N gso|" ) ;
> @{ccyymmddhh} = <INPUT> ;
> chomp( @{ccyymmddhh} ) ;
> close( INPUT ) ;
*Shudder*
>I think that I should clean this up and reprogram this to use DBD::mysql
>rather than the way he does it here.
That's an understatement.
>Anyone have any idea if it would improve performance?
The only way to be sure is to try both ways, but... I would bet long odds
that the performance will be greatly improved. The above has to fire off a
subprocess and build up and tear down a connection for each query. If the
DBI way turns out to be slower, look me up at the Perl Conference and I'll
buy you a drink. So, I suspect, will Tim Bunce :-)
>I'd love to hear from people that have gone doing it this way to using DBI.
>
>Obviously I can run benchmarks before and after and see which takes longer,
>and I think that using DBI is not only much easier to read and manage, but
>probably a little faster. Just seeking the advice of others.
Go with easier to read and manage first. The above code is NOT capable of
being reused in obvious ways (suppose $query contained quote marks or shell
metacharacters).
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]