Jump to content

php vs perl speed issues


obewan

Recommended Posts

I am crunching mysql data and was able to write some php in a conventional script as well as command line version that worked, but it was slow with less than 30 records taking about 45 seconds.  Perl version took less than 5 or 10 seconds max. I have to process over 1200 records.....php hangs and times out.

So I went with perl, calling it from php with exec().

 

Why the huge difference between php and perl - particularly when both are called form the command line?

 

???

Link to comment
Share on other sites

<?

$dweb =& new dWeb();

$db =& $dweb->dbConnect();

$uniqueOrders = array(); // holds unique lines

$uniqueAccounts = array(); // holds unique lines

$lName = array(); // holds unique lines

$fName = array(); // holds unique lines

$paymentT = array(); // holds unique lines

$paymentA = array(); // holds unique lines

$count = 0;

$process = 0;

 

$result = $db->query("SELECT Phone,Account,LastName,FirstName,

PaymentType,PaymentAmount,ID FROM table1 WHERE

PaymentDate = '$mydate' AND orders_id = 0");

// Always check that $result is not an error

if (DB::isError($result)) {

        die ($result->getMessage());

}

 

while ($row = $result->fetchRow()) {

$result2 = $db->query("SELECT table2.reseller_orderid

from table2 WHERE table2.omsCustomerid = '$row[1]' limit 1");

 

if($row2 = $result2->fetchRow()) {

    $myid = $row2[0];

    // get result and update table1.orders_id

$update =& $db->query("UPDATE table1

SET orders_id = $myid WHERE Phone = $row[0]");

}else{

$result3 = $db->query("SELECT table2.reseller_orderid

from table2 WHERE table2.lead_telephone = '$row[0]' limit 1");

if($row3 = $result3->fetchRow()) {

    $myid = $row3[0];

    // get result and update table1.orders_id

$update =& $db->query("UPDATE table1

SET orders_id = $myid WHERE ID = $row[6]");

}else{

    // collect info on the rows that fail to find an id

array_push($uniqueOrders, $row[0]);

array_push($uniqueAccounts, $row[1]);

array_push($lName, $row[2]);

array_push($fName, $row[3]);

array_push($paymentT, $row[4]);

array_push($paymentA, $row[5]);

}

}

$result2->free();

}  // end while

$result->free();

?>

/*

 

sample data

 

"Customer Name" "Account Number" "Type" "AccessCardNumber" "Status" "PhoneNumber" "Owner" "Zip" "Start Date" "Disconnection Date" "Payment Name" "Reason Code" "PPC/Chargeback"

"tom" "804" "REG" "0595" "xL" "5551212" "romulas" "<Null>" "11/11/2006" "11/20/2006" "CBPPC-1" "<Null>" "-180.00"

"dick" "721" "REG" "0978" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "<Null>" "51" "0.00"

"dick" "721" "REG" "0142" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "<Null>" "51" "0.00"

"dick" "721" "REG" "0165" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "<Null>" "51" "0.00"

"dick" "721" "REG" "0183" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "BONUS" "<Null>" "25.00"

"dick" "721" "REG" "0183" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "ABONUS" "<Null>" "25.00"

"dick" "721" "REG" "0183" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "RSP" "<Null>" "50.00"

"dick" "721" "REG" "0183" "xT" "5551213" "romulas" "23098" "2/17/2007" "<Null>" "P1" "<Null>" "205.00"

"harry" "345" "REG" "0441" "xT" "5551214" "romulas" "23638" "2/20/2007" "<Null>" "<Null>" "51" "0.00"

"harry" "345" "REG" "0875" "xT" "5551214" "romulas" "23638" "2/20/2007" "<Null>" "QBONUS" "<Null>" "25.00"

"harry" "345" "REG" "0875" "xT" "5551214" "romulas" "23638" "2/20/2007" "<Null>" "RSP" "<Null>" "50.00"

"harry" "345" "REG" "0875" "xT" "5551214" "romulas" "23638" "2/20/2007" "<Null>" "P-1" "<Null>" "205.00"

 

 

 

*/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.