From: mauroi at digbang dot com Operating system: PHP version: Irrelevant PHP Bug Type: Performance problem Bug description: pg_field_type inner query slows down scripts
Description: ------------ Using PostgreSQL we're casting every field we get from the database with the corresponding object (datetime, oid (lob), etc.). With that in mind, we're using the pg_field_type function that returns the needed information (data type). Lately we were having performance problems in the server, so, looking at php's source code we found that pg_field_type makes the following query: 'select oid,typname from pg_type' Since every new postgresql table generates a new type and the database has up to 500 tables, that query takes 500 ms to execute (just to know the type of a field, 80% of the page execution). So our workaround was to create a new function called pg_field_type_oid that only returns the oid of the field type (no internal query). So now the application has to know the corresponding datatype for the type oid. Our pages now execute in 90ms. Reproduce code: --------------- any call to pg_field_type -- Edit bug report at http://bugs.php.net/?id=31393&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31393&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31393&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31393&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31393&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31393&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31393&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31393&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31393&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31393&r=support Expected behavior: http://bugs.php.net/fix.php?id=31393&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31393&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31393&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31393&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31393&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31393&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31393&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31393&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31393&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31393&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31393&r=mysqlcfg