Do not override the sequence_range setting in COPY
authorPavan Deolasee <[email protected]>
Thu, 28 Jan 2016 10:27:54 +0000 (15:57 +0530)
committerPavan Deolasee <[email protected]>
Fri, 29 Jan 2016 08:10:33 +0000 (13:40 +0530)
The default value of this parameter has now been hiked to 1000. So there is no
good reason to override this in COPY, if the user has explicitly set it back to
1. Honor user defined value in all cases.

We can possibly flag a warning if sequences are being incremened too fast and
the current value of sequence_range is set too low. But no compelling need to
do that just now.

src/backend/commands/copy.c

index 3fc611570a5816221feb3f00e6c3fdc15b700a94..ca3b8678f271425f2c404c52fbc3d2ae53011eb7 100644 (file)
@@ -846,9 +846,6 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
        bool            is_from = stmt->is_from;
        bool            pipe = (stmt->filename == NULL);
        Relation        rel;
-#ifdef XCP
-       int oldSeqRangeVal = SequenceRangeVal;
-#endif
        Oid                     relid;
        Node       *query = NULL;
        List       *range_table = NIL;
@@ -983,26 +980,6 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
                rel = NULL;
        }
 
-#ifdef XCP
-       /*
-        * The COPY might involve sequences. We want to cache a range of
-        * sequence values to avoid contacting the GTM repeatedly. This
-        * improves the COPY performance by quite a margin. We set the
-        * SequenceRangeVal GUC parameter to bring about this effect.
-        * Note that we could have checked the attribute list to ascertain
-        * if this GUC is really needed or not. However since this GUC
-        * only affects nextval calculations, if sequences are not present
-        * no harm is done..
-        *
-        * The user might have set the GUC value himself. Honor that if so
-        */
-
-#define MAX_CACHEVAL   1024
-       if (rel && getOwnedSequences(RelationGetRelid(rel)) != NIL &&
-                               SequenceRangeVal == DEFAULT_CACHEVAL)
-               SequenceRangeVal = MAX_CACHEVAL;
-#endif
-
        if (is_from)
        {
                Assert(rel);
@@ -1036,11 +1013,6 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
                EndCopyTo(cstate);
        }
 
-#ifdef XCP
-       /* Set the SequenceRangeVal GUC to its earlier value */
-       SequenceRangeVal = oldSeqRangeVal;
-#endif
-
        /*
         * Close the relation. If reading, we can release the AccessShareLock we
         * got; if writing, we should hold the lock until end of transaction to