Weird database stuff.

From: Date: Tue, 13 Nov 2001 07:58:04 +0000
Subject: Weird database stuff.
Groups: php.general 
Request: Send a blank email to php-general+get-74382@lists.php.net to get a copy of this message
Hey fellow PHP-codemonkeys. :) Let me start by laying out some facts: SELECT e.NAME AS customer, g.NAME AS driver_lastname, g.FIRSTNAME AS driver_firstname, $CommonSQL, COUNT(g.NAME) AS number FROM ENTITY e, ENTITY g, EXPERTISE_FILE f, DAMAGE_CASE d WHERE (f.CUSTOMER = '$CustomerID') AND (e.ID = f.CUSTOMER) AND (g.ID = f.DRIVER) AND (d.OWNER_EXP_FILE = f.ID) AND (f.DATE_REPORT BETWEEN '$StartDate' AND '$EndDate') GROUP BY e.NAME, g.NAME, g.FIRSTNAME The query above is one of the statistics gathering queries in my application. This one will run flawlessly. If however I add this condition: "AND (f.DRIVER = '$DriverID')" before "AND (g.ID = f.DRIVER), the script will eat all CPU and RAM (and eventually swap aswell) on my PowerEdge 2500SC. If I run both queries from inside psql (I use PostgreSQL), they -both- (!) complete within split seconds... If I leave set_time_limit() on the default of 30 secs, my script will time out somewhere around these lines (though it seems like coincidence...): function CalcDenied ( $Requested, $Agreed ) { $Denied = $Requested - $Agreed; --> Timeout here if ($Denied < 0) --> Sometimes here { $Denied = 0; } return $Denied; } To me, this does not seem to make any sense, especially since the first query (without the additional condition) runs fine, whilst it has to return many more rows. Does anyone have any idea what could be going on? If you reply, please include a CC for me, as I am on digest (I don't have time to sort through all the messages at work anyway, but I do contribute from home. :) Thanks -- Alexander Deruwe (aderuwe@aqs-carcontrol.be) AQS-CarControl

« previous php.general (#74382) next »