#25859 [Opn->Bgs]: php.exe consumes 100% cpu
| From: | mboeren@php.net | Date: | Tue, 14 Oct 2003 10:20:45 +0000 |
| Subject: | #25859 [Opn->Bgs]: php.exe consumes 100% cpu | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48962@lists.php.net to get a copy of this message | ||
ID: 25859
Updated by: mboeren@php.net
Reported By: mfelden at gsd-web dot de
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: windows 2000 server
PHP Version: 4.3.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
I'm assuming the select query gets a lot of data: since dbx_query
retrieves and buffers all data this could lead to a very long execution
time.
If this is not the case, please re-open this bug report.
Otherwise, read on:
First: alter your sql statement to only retrieve fields you actually
need, such as 'field' and 'id'. Don't use * in a select statement.
Second: your query() function is not very efficient: it would be much
better to put the dbx_connect() and dbx_close() calls outside the
function, preferably at the beginning and end of the script or perhaps
the get_data() function. And when you do that you might as well skip
the query() function definition altogether :-)
If you are retrieving a lot of records, the new version of dbx_query()
(in CVS only) has support for the DBX_RESULT_UNBUFFERED flag where you
can retrieve data record by record, which is probably what you want as
it is a lot more efficient.
If you are unable to get the CVS version, perhaps you should use the
mysql_unbuffered_query() directly...
Previous Comments:
------------------------------------------------------------------------
[2003-10-14 06:00:28] mfelden at gsd-web dot de
Description:
------------
PHP is running on the local http-server IIS. A script loaded in IE 5
causes a new instance of php.exe running on the server. It instantly
consumes 100% of the cpu power. This blocks the server, so the query
could not be completed. The IIS sends a Timeout after 30 seconds. I
can't change it, due to the MMC which says, there is no IIS. Even after
closing the IE-Window php.exe is consuming 100% of the cpu power for
the next say 5 minutes. During this php.exe dis- and appears in the
process list again and again. In php.ini php_iisfunc.dll is commented
out.
It is no fun.
Reproduce code:
---------------
<html><head><title>Import</title></head>
<body><h3>Daten holen</h3>
<form action='daten.php' method="POST">
<input name=ok type=submit value=OK>
</form></body></html>
<?php
if($_POST['ok']){get_data();}
function get_data()
{
$query = "SELECT * FROM corpus WHERE gms is not null and id>590 and
id<691";
$result = query($query, $source);
for($i = 0; $i < $result->rows; $i++)
{
$query = "UPDATE corpus SET strasse ='" .
$result->data[$i]['field'] . "' WHERE id = " .
$result->data[$i]['id'];
query($query);
}
}
}
function query($query)
{
$link = dbx_connect (DBX_MSSQL, "1.2.3.4", "db", "user",
"pwd",
DBX_PERSISTENT| DBX_RESULT_INFO) or die ("Fehler beim Verbinden");
$result = dbx_query($link, $query);
dbx_close ($link);
return $result;
}
?>
Expected result:
----------------
Query completed
Actual result:
--------------
Timeout after 30 sec
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25859&edit=1