php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3235 wasting many time in indexing operations in large loop
Submitted: 2000-01-17 10:19 UTC Modified: 2001-02-10 14:32 UTC
From: libes at com dot univ-mrs dot fr Assigned:
Status: Closed Package: Performance problem
PHP Version: 3.0.12 OS: linux redhat 6.0
Private report: No CVE-ID: None
 [2000-01-17 10:19 UTC] libes at com dot univ-mrs dot fr
hi to all and many thanks if you can tell me something...

we dump a  little mysql database (90000 records)  via php3-mysql
we write the records in an ascii file in order to get it via ftp
in a html frontend page we can select some buttons before the sql
query is launched.. these buttons are recuperated in the php code in a little loop where we compose the name of the variables...

our problem is that we waste many many time (45sec) inside the main loop
(while $row) just to make the result line

/* $bouton=strtok($liste," ");
                while($bouton) {
        		   $ligne=$ligne.$row["$bouton"]."\t";
                                $bouton = strtok(" ");
        	  }	
*/
if  we comment these lines (and we hardcode the composition of the result line) above we gain half the total time

am i clear?
thanks if you have a solution? or maybe we touch the limit of the system?
ML

--------- to make a list of selected buttons---------
$liste="";
for ($k=1; $k<21; $k++)
	{
	 $s="b".$k;
	 $long=strlen(${$s});
	if ($long>0) {
           $liste=$liste.${$s}." " ;
        }
}
chop($liste);

--------to dump the selected colums--------
while ($row )  /*# 90000 records*/
		{ 
	  /* $bouton=strtok($liste," ");
                while($bouton) {
        		   $uneligne=$uneligne.$row["$bouton"]."\t";
                                $bouton = strtok(" ");
        	  }	
               */

/* we gain many time if the above lines are  comented ... why?*/
	   $uneligne=$row["Latitude"] ."       ". $row["Longitude"] ." ".  $row["Date"] ."     ". $row["ProfMes"]  ."  ". $row["Temp"]  ."     ". $row["Cond"]  ."     ". $row["TempPot"]  ."  ". $row["Sal"]  ."      ". $row["Sig0"]  ."     ". $row["Sig2"]  ."     ". $row["Tur"]  ."      ". $row["Fluo"]  ."     ". $row["O2d"]
. "\n" ;
                $uneligne=$uneligne."\n"; 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 14:32 UTC] jimw@php.net
this should be faster in php4, i think.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC