ID:          31393
 Comment by:  yohgaki at ohgaki dot net
 Reported By: mauroi at digbang dot com
 Status:      Assigned
 Bug Type:    PostgreSQL related
 PHP Version: Irrelevant
 Assigned To: yohgaki
 New Comment:

Although, it seems 500 ms execution time for the query is too long.
(Try vaccumedb -f , if you haven't done yet) The patch itself seems
good. Question is getting OID of data type is good for anything else.


Previous Comments:
------------------------------------------------------------------------

[2005-01-03 22:39:59] [EMAIL PROTECTED]

Assigning to the maintainer.

------------------------------------------------------------------------

[2005-01-03 22:18:54] mauroi at digbang dot com

http://webmail.digbang.com/patch_type_oid.diff
Thanks in advance

------------------------------------------------------------------------

[2005-01-03 22:14:35] [EMAIL PROTECTED]

Can you provide a patch of this in unified diff format? (External
please, and provide a link)

------------------------------------------------------------------------

[2005-01-03 22:07:18] mauroi at digbang dot com

I can send the patch with the new function (tested on PHP-5.0.3) in
case you need it. Just tell me where.
Thanks in advance.

------------------------------------------------------------------------

[2005-01-03 22:02:31] mauroi at digbang dot com

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 this bug report at http://bugs.php.net/?id=31393&edit=1

Reply via email to