Bug #70092 [Asn->Ver]: pg_field_type() is too slow

From: Date: Sat, 25 Jul 2015 12:41:42 +0000
Subject: Bug #70092 [Asn->Ver]: pg_field_type() is too slow
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194701@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70092&edit=1 ID: 70092 Updated by: cmb@php.net Reported by: yohgaki@php.net Summary: pg_field_type() is too slow -Status: Assigned +Status: Verified Type: Bug Package: PostgreSQL related PHP Version: master-Git-2015-07-17 (Git) Assigned To: yohgaki Block user comment: N Private report: N New Comment: For some reason the buffering of the field names in get_field_name() does not work, and so for each call to pg_field_type() the else clause ("hash all oids")[1] is executed again. [1] <https://github.com/php/php-src/blob/php-7.0.0beta2/ext/pgsql/pgsql.c#L2349> Previous Comments: ------------------------------------------------------------------------ [2015-07-17 21:16:58] yohgaki@php.net Description: ------------ Somehow pg_field_type() became very slow. Other functions that share the same code pg_field_name()/etc is not affected. Test script: --------------- <?php $db = pg_connect('host=localhost') or die('Cannot connect db'); $res = pg_query('SELECT * FROM test'); $start = microtime(true); for ($i = 0; $i < 10000; $i++) { pg_field_type($res, 1); } echo 'pg_field_type(): '.(microtime(true)-$start)."\n"; $start = microtime(true); for ($i = 0; $i < 10000; $i++) { pg_field_name($res, 1); } echo 'pg_field_name(): '.(microtime(true)-$start)."\n"; $start = microtime(true); for ($i = 0; $i < 10000; $i++) { pg_field_size($res, 1); } echo 'pg_field_type(): '.(microtime(true)-$start)."\n"; Expected result: ---------------- pg_filed_type() should be as fast as pg_filed_name()/etc Actual result: -------------- PHP 7 and master [yohgaki@dev PHP-master]$ ./php-bin ../t.php pg_field_type(): 3.1048510074615 pg_field_name(): 0.0023491382598877 pg_field_type(): 0.0014290809631348 PHP 5.6 [yohgaki@dev PHP-master]$ php ../t.php pg_field_type(): 0.0019080638885498 pg_field_name(): 0.0013489723205566 pg_field_type(): 0.0010430812835693 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70092&edit=1

« previous php.bugs (#194701) next »