From: | "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com> |
---|---|
To: | vignesh C <vignesh21(at)gmail(dot)com> |
Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, "Andres Freund" <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Ants Aasma <ants(at)cybertec(dot)at>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, "Alastair Turner" <minion(at)decodable(dot)me>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Subject: | RE: Parallel copy |
Date: | 2020-10-18 02:17:07 |
Message-ID: | e5e4991a175c4778b0574d5bbc071848@G08CNEXMBPEKD05.g08.fujitsu.local |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Vignesh,
After having a look over the patch,
I have some suggestions for
0003-Allow-copy-from-command-to-process-data-from-file.patch.
1.
+static uint32
+EstimateCstateSize(ParallelContext *pcxt, CopyState cstate, List *attnamelist,
+ char **whereClauseStr, char **rangeTableStr,
+ char **attnameListStr, char **notnullListStr,
+ char **nullListStr, char **convertListStr)
+{
+ uint32 strsize = MAXALIGN(sizeof(SerializedParallelCopyState));
+
+ strsize += EstimateStringSize(cstate->null_print);
+ strsize += EstimateStringSize(cstate->delim);
+ strsize += EstimateStringSize(cstate->quote);
+ strsize += EstimateStringSize(cstate->escape);
It use function EstimateStringSize to get the strlen of null_print, delim, quote and escape.
But the length of null_print seems has been stored in null_print_len.
And delim/quote/escape must be 1 byte, so I think call strlen again seems unnecessary.
How about " strsize += sizeof(uint32) + cstate->null_print_len + 1"
2.
+ strsize += EstimateNodeSize(cstate->whereClause, whereClauseStr);
+ copiedsize += CopyStringToSharedMemory(cstate, whereClauseStr,
+ shmptr + copiedsize);
Some string length is counted for two times.
The ' whereClauseStr ' has call strlen in EstimateNodeSize once and call strlen in CopyStringToSharedMemory again.
I don't know wheather it's worth to refacor the code to avoid duplicate strlen . what do you think ?
Best regards,
houzj
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-10-18 02:41:43 | Re: pg_restore error message during ENOSPC with largeobj |
Previous Message | Justin Pryzby | 2020-10-18 01:02:32 | pg_restore error message during ENOSPC with largeobj |