fix possible optimizations in ATExecAttachPartition()

From: Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: fix possible optimizations in ATExecAttachPartition()
Date: 2017-06-13 09:08:34
Message-ID: CAOgcT0Neue5EgZFHz9qLox1kNENFOv90XqhXzNm97+VPba9Ucw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I was doing some testing for my default partitioning work, and I realized
that
there seem to be a some optimization possible (and I think we should really
have
this optimization) for logic around handling the "key IS NOT NULL"
constraints
followed by predicate_implied_by() call.

1. Consider, if predicate_implied_by() returns false, in that case
skip_validate
is left set to false, and we really do not want to do lots of stuff followed
this decision just to prove that the scan cannot be avoided(which is already
decided in this case) if there is no NOT NULL constraint on the partition
key
column.

2. Further, if we have already decided not to skip the scan, we should
really have
a break in following if block:

if (!partition_accepts_null &&
(partattno == 0 ||
!bms_is_member(partattno, not_null_attrs)))
skip_validate = false;

I have made above changes in the attached patch.
PFA, and let me know if I am missing something here.

Regards,
Jeevan Ladhe

Attachment Content-Type Size
fix_atexecattahpartition.patch application/octet-stream 2.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-06-13 09:22:54 Re: fix possible optimizations in ATExecAttachPartition()
Previous Message Alex Kliukin 2017-06-13 08:58:42 Re: [HACKERS] Why restore_command is called for existing files in pg_xlog?