Bug #70092 [Ana->Csd]: pg_field_type() is too slow
| From: | yohgaki@php.net | Date: | Sat, 25 Jul 2015 20:29:56 +0000 |
| Subject: | Bug #70092 [Ana->Csd]: pg_field_type() is too slow | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194709@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: yohgaki@php.net
Reported by: yohgaki@php.net
Summary: pg_field_type() is too slow
-Status: Analyzed
+Status: Closed
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:
Automatic comment on behalf of yohgaki
Revision: http://git.php.net/?p=php-src.git;a=commit;h=62515a1dbb6132051d657ce4df7cc5da32b1a039
Log: Fixed Bug #70092 pg_field_type() is too slow
Previous Comments:
------------------------------------------------------------------------
[2015-07-25 20:17:27] yohgaki@php.net
Simply freed smart_str instead of setting length to 0.
PHP7/master without --enable-debug
[yohgaki@dev PHP-master]$ ./php-bin ../t.php
pg_field_type(): 0.0013771057128906
pg_field_name(): 0.00064301490783691
pg_field_type(): 0.00048398971557617
Fedora22's PHP 5.6
[yohgaki@dev PHP-master]$ php ../t.php
pg_field_type(): 0.0018699169158936
pg_field_name(): 0.0012152194976807
pg_field_type(): 0.0011649131774902
------------------------------------------------------------------------
[2015-07-25 19:28:33] yohgaki@php.net
@cmb
Thanks! I thought it seems freeing is required, too. I'll check the behavior using gdb later.
------------------------------------------------------------------------
[2015-07-25 14:05:58] cmb@php.net
Simply setting the length of the smart_string's zend_string to
zero[1] won't work, because that causes the same zend_string to be
used as key of the list hashtable again and again. Instead it
seems that the smart_string's zend_string has to be free (see the
attached patch "pg_field_type").
Yasuo, please have a look at this issue.
[1] <https://github.com/php/php-src/blob/php-7.0.0beta2/ext/pgsql/pgsql.c#L2371>
------------------------------------------------------------------------
[2015-07-25 14:04:43] cmb@php.net
The following patch has been added/updated:
Patch Name: pg_field_type
Revision: 1437833083
URL: https://bugs.php.net/patch-display.php?bug=70092&patch=pg_field_type&revision=1437833083
------------------------------------------------------------------------
[2015-07-25 12:41:41] cmb@php.net
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>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=70092
--
Edit this bug report at https://bugs.php.net/bug.php?id=70092&edit=1