Re: Needless additional partition check in INSERT?

Amit Langote <langote_amit_f8@lab.ntt.co.jp>

From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: Amit Khandekar <amitdkhan.pg@gmail.com>, David Rowley <david.rowley@2ndquadrant.com>
Cc: Simon Riggs <simon@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Robert Haas <robertmhaas@gmail.com>, Amit Langote <amitlangote09@gmail.com>
Date: 2018-05-14T04:49:52Z
Lists: pgsql-hackers
On 2018/05/11 18:43, Amit Khandekar wrote:
> This looks better (it will avoid unnecessary ExecConstraints() call) :
> 
> if (resultRelInfo->ri_PartitionRoot == NULL ||
>      (resultRelInfo->ri_TrigDesc &&
>       resultRelInfo->ri_TrigDesc->trig_insert_before_row))
>     check_partition_constr = resultRelInfo->ri_PartitionCheck;

You'd be assigning a List pointer to a bool variable with this.  Maybe you
meant:

    check_partition_constr = (resultRelInfo->ri_PartitionCheck != NIL);

Thanks,
Amit



Commits

  1. Don't needlessly check the partition contraint twice