|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-07-04 22:24 UTC] tigger at ebom dot org
an ODBC query that takes a long time to excute (> 30 sec) will crash php and requires apache to restart. This is when loading php as an apache modual or as a CGI apache 1.3.20 (win2k) php 4.0.6 (win2k) SQL2000 (win2k) The SQL2000 database has over 30 million records and is performing a scan (on indexed records) I'm more than willing to test code or help out to fix this btw PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 17:00:01 2025 UTC |
We played with the indexes and now the data is returning a lot faster (2 seconds where it was over 60!) Someone who was meant to have placed these indexes did not test for this query :] Anyway, you can still crash php/apache with the following code IF you go beyond the script timeout limits. Apache spawns an instance for each request so it only crashes individual instances of apache, but its still not to good. I think if you load php as a CGI you can run into bigger problems. Here is some code; <html> <body> <?php //change these to suit your set-up //change $PC to any 4 numbers $PC = "2000"; $DB_DSN = "SomeDNS"; $DB_USR = "SomeUser"; $DB_PWD = "SomePass"; $query = "SELECT TOP 500 PVMAL.STATE, " . " PVMAL.POSTCODE, " . " PVMAL.UNIT, " . " PVMAL.UNIT_NO, " . " PVMAL.HOUSE_NO, " . " PVMAL.ST_NAME, " . " PVMAL.ST_TY, " . " PVSALES.SALE_PRICE, " . " PVSALES.SALE_DATE, " . " PVSUBURB.SUBURB " . " FROM PVMAL " . " JOIN PVSUBURB " . " ON PVMAL.SUBURB_ID = PVSUBURB.SUBURB_ID " . " JOIN PVSALES " . " ON PVMAL.MALID = PVSALES.MALID " . "WHERE PVMAL.POSTCODE = " . $PC . " AND " . "PVSALES.SALE_DATE > '01-jan-2000' " . "ORDER BY PVSALES.SALE_DATE DESC"; $alt = 0; $CON = odbc_connect($DB_DSN, $DB_USR, $DB_PWD); $RS = odbc_exec($CON,$query); if (odbc_num_rows($RS) > 0) { //echo($State . " " . $PC); ?> <table cellspacing="2" cellpadding="3" border="0"> <tr> <td width="210"><b>Sales History With Valid Address</b></td> <td width="65"><b>Sale Price</b></td> <td width="65"><b>Sale Date</b></td> <td width="55"><b>Type</b></td> <td width="65"><b>Details</b></td> </tr> <? for ($i=1;odbc_fetch_row($RS,$i);$i++) { $Address1 = "xx " . trim(odbc_result($RS,"ST_NAME")) . " " . trim(odbc_result($RS,"ST_TY")) . ", "; $Address2 = odbc_result($RS,"SUBURB") . ", " . odbc_result($RS,"STATE") . " " . odbc_result($RS,"POSTCODE"); if (odbc_result($RS,"UNIT") == "Y") { $Address1 = "x/" . $Address1; $PropType = "UNIT"; } else { $PropType = "HOUSE"; } $SalePrice = "\$" . "xxxxxx"; $SD = explode("-",substr(odbc_result($RS,"SALE_DATE"),0,10)); $SaleDate = "$SD[2]/$SD[1]/$SD[0]"; $PropDetails = " "; if ($alt == 1) { $bgcol = "FFFFFF"; } else { $bgcol = "FFE2CC"; } ?> <tr bgcolor="#<? echo($bgcol); ?>" valign="top"> <td><? echo($Address1 . "<br />" . $Address2); ?></td> <td><? echo($SalePrice); ?></td> <td><? echo($SaleDate); ?></td> <td><? echo($PropType); ?></td> <td><? echo($PropDetails); ?></td> </tr> <? $alt = abs($alt - 1); $Address = ""; $SalePrice= ""; $SaleDate = ""; odbc_fetch_row($RS); // MoveNext } } odbc_close($CON); if (($i == 1) && ($alt == 0)) { ?> <tr> <td colspan="5" bgcolor="#FFE2CC">There have been no sales in your specified postcode in the last twelve months.</td> </tr> <? } ?> </table> </body> </html>