Hi,

When reviewing some pg_dump related code, I found some existsing code
(getTableAttrs() and dumpEnumType()) invoke PQfnumber() repeatedly which seems
unnecessary.

Example
-----
                for (int j = 0; j < ntups; j++)
                {
                        if (j + 1 != atoi(PQgetvalue(res, j, PQfnumber(res, 
"attnum"))))
-----

Since PQfnumber() is not a cheap function, I think we'd better invoke
PQfnumber() out of the loop like the attatched patch.

After applying this change, I can see about 8% performance gain in my test 
environment
when dump table definitions which have many columns.

Best regards,
Hou zhijie

Attachment: 0001-Avoid-repeated-PQfnumber.patch
Description: 0001-Avoid-repeated-PQfnumber.patch

Reply via email to