Web Hosting Talk







View Full Version : what is faster ? (mysql+perl)


Slike
01-26-2005, 12:12 PM
-----| 1 |-----

my $query="select param1, param2 from table";
my $m_output = $db->prepare($query);
$m_output->execute();
my ($param1, $param2) = $m_output->fetchrow_array();

$d = $param1*$param2;

print $d;

-----| 2 |-----

my $query="select param1 * param2 from table";
my $m_output = $db->prepare($query);
$m_output->execute();
my ($d) = $m_output->fetchrow_array();

print $d;


----------------

What`s faster ?:confused:

thx

k2host
01-26-2005, 03:34 PM
Why not test it and print out the time it took for the operation to run.

Chas
01-26-2005, 05:43 PM
I would say #2. Anything you can do at the DB level tends to be faster than doing it in Perl. Buts, as k2host suggested, profile your code and see for yourself.

http://builder.com.com/5100-6387-5278558.html

~Charlie

hiryuu
01-26-2005, 07:32 PM
I also suspect the second one will be faster (less data passing and parsing), but it's nothing compared to the two context switches it takes to actually run the query.

rtstats
01-27-2005, 01:54 PM
Option 2. SQL is faster than PHP.

Ten X
01-27-2005, 02:03 PM
deffinately #2 me personally i think its not only easier but yes faster as well