Bug #75705 [Opn->Dup]: pg_field_type() slow and consumes CPU on a large database
| From: | cmb@php.net | Date: | Mon, 10 Oct 2022 08:06:28 +0000 |
| Subject: | Bug #75705 [Opn->Dup]: pg_field_type() slow and consumes CPU on a large database | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-242555@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75705&edit=1
ID: 75705
Updated by: cmb@php.net
Reported by: dmitry dot kunilov at gmail dot com
Summary: pg_field_type() slow and consumes CPU on a large
database
-Status: Open
+Status: Duplicate
Type: Bug
Package: PostgreSQL related
PHP Version: 7.2.0
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Closing as duplicate of https://github.com/php/php-src/issues/9692.
Previous Comments:
------------------------------------------------------------------------
[2017-12-19 13:01:40] dmitry dot kunilov at gmail dot com
Description:
------------
Our database has around 25K tables. Whenever a PHP script does a first call to pg_field_type(), it
consumes a lot of CPU, memory and network traffic.
This is reproducible with all PHP versions from 5 to 7.2
The problem was narrowed down to the following query performed from ext/pgsql/pgsql.c
get_field_name():
select oid,typname from pg_type
As postgresql defines several types for each table in the database, the above query produces over
76K rows on our system. All of those are put into a hashmap by get_field_name().
Obviously, rowset types present in pg_type table cannot be used as field types, and have to be
excluded from the query.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75705&edit=1