Hello, Even if skipping header is done only once its checked and skipped in a loop. If I don’t miss something it can be done out side a loop like attached patch
regards Surafel
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 4f04d122c3..4e7709d7bf 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -3004,6 +3004,13 @@ CopyFrom(CopyState cstate) errcallback.previous = error_context_stack; error_context_stack = &errcallback; + /* on input just throw the header line away */ + if ( cstate->header_line) + { + cstate->cur_lineno++; + (void) CopyReadLine(cstate); + } + for (;;) { TupleTableSlot *myslot; @@ -3642,14 +3649,6 @@ NextCopyFromRawFields(CopyState cstate, char ***fields, int *nfields) /* only available for text or csv input */ Assert(!cstate->binary); - /* on input just throw the header line away */ - if (cstate->cur_lineno == 0 && cstate->header_line) - { - cstate->cur_lineno++; - if (CopyReadLine(cstate)) - return false; /* done */ - } - cstate->cur_lineno++; /* Actually read the line into memory here */