php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71409 [Performance] include build in types in get_field_name()
Submitted: 2016-01-18 17:15 UTC Modified: 2016-04-24 04:22 UTC
From: php at sdiz dot net Assigned:
Status: No Feedback Package: PostgreSQL related
PHP Version: 5.6.17 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
12 + 20 = ?
Subscribe to this entry?

 
 [2016-01-18 17:15 UTC] php at sdiz dot net
Description:
------------
Oid of PostgreSQL buildin types (those defined in src/include/catalog/pg_type.h) should be hardcoded for performance.

Reason:
Currently, PHP do a "SELECT oid,typename FROM pg_type" on the first time get_field_name() is called. Results are cached.

In most case, it is called for build-in types, which can use hardcoded value in pg_type.h. The pg_type query is needed only if it miss.

I have some (non-PHP) application that create/drop lots of tables dynamically, pg_type is very bloated and a simple select all take ~1 second. If you can cut it down, it will be a great performance gain for me.

---
The related code is at: https://github.com/php/php-src/blob/master/ext/pgsql/pgsql.c#L2389


	if ((field_type = zend_hash_find_ptr(list, str.s)) != NULL) {
		ret = estrdup((char *)field_type->ptr);
	} else { /* hash all oid's */
		int i, num_rows;
		int oid_offset,name_offset;
		char *tmp_oid, *end_ptr, *tmp_name;
		zend_resource new_oid_entry;

		if ((result = PQexec(pgsql, "select oid,typname from pg_type")) == NULL || PQresultStatus(result) != PGRES_TUPLES_OK) {
			if (result) {
				PQclear(result);
			}


Expected result:
----------------
The pg_type query is run only if I query on custom type.

Actual result:
--------------
The pg_type query is run always.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-15 10:26 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-04-15 10:26 UTC] ab@php.net
Please provide some test code to illustrate the issue.

Thanks.
 [2016-04-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 09:01:30 2024 UTC