From: | "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Avoid repeated PQfnumber() in pg_dump |
Date: | 2021-07-14 08:54:32 |
Message-ID: | OS0PR01MB57164C392783F29F6D0ECA0B94139@OS0PR01MB5716.jpnprd01.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 | Content-Type | Size |
---|---|---|
0001-Avoid-repeated-PQfnumber.patch | application/octet-stream | 6.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2021-07-14 09:09:54 | Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view? |
Previous Message | Peter Smith | 2021-07-14 08:33:37 | Re: [HACKERS] logical decoding of two-phase transactions |