mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Speed up COPY into tables with DEFAULT nextval()
Previously the presence of a nextval() prevented the use of batch-mode COPY. This patch introduces a special case just for nextval() functions. In future we will introduce a general case solution for labelling volatile functions as safe for use.
This commit is contained in:
@ -2519,9 +2519,20 @@ BeginCopyFrom(Relation rel,
|
||||
defmap[num_defaults] = attnum - 1;
|
||||
num_defaults++;
|
||||
|
||||
/* Check to see if we have any volatile expressions */
|
||||
/*
|
||||
* If a default expression looks at the table being loaded, then
|
||||
* it could give the wrong answer when using multi-insert. Since
|
||||
* database access can be dynamic this is hard to test for
|
||||
* exactly, so we use the much wider test of whether the
|
||||
* default expression is volatile. We allow for the special case
|
||||
* of when the default expression is the nextval() of a sequence
|
||||
* which in this specific case is known to be safe for use with
|
||||
* the multi-insert optimisation. Hence we use this special case
|
||||
* function checker rather than the standard check for
|
||||
* contain_volatile_functions().
|
||||
*/
|
||||
if (!volatile_defexprs)
|
||||
volatile_defexprs = contain_volatile_functions((Node *) defexpr);
|
||||
volatile_defexprs = contain_volatile_functions_not_nextval((Node *)defexpr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user