Reputation: 1755
If pg_field_type()
makes a call to database in any way, it can be expensive. If not, it is "cheap" in the boundaries of being cheap in PHP.
So the question is, will calling pg_field_type() make any extra communication with the database, or is it all just getting metadata from the result that PHP already got from the database? Being yes or no, is it always the case and why?
Upvotes: 0
Views: 46
Reputation: 27404
Yes, there is an extra communication (per worker process) with the database when you first attempt to get type names.
PHP's pg module will query the entire pg_type
table and cache the result.
So if you need a "cheap" method, use pg_field_type_oid
and manually convert from oid to type name.
Upvotes: 1