0/NULL/NIL assignments in build_*_rel()

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: 0/NULL/NIL assignments in build_*_rel()
Date: 2017-02-06 04:49:51
Message-ID: CAFjFpRcnVDb1ukbuCJYWRTvMJ_c+mRj0w-5oPTbi5dPBmCg-yQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
Both build_simple_rel() and build_join_rel() allocate RelOptInfo using
makeNode(), which returned a zeroed out memory. The functions then
assign values like false, NULL, 0 or NIL which essentially contain
zero valued bytes. This looks like needless work. So, we are spending
some CPU cycles unnecessarily in those assignments. That may not be
much time wasted, but whenever someone adds a field to RelOptInfo,
those functions need to be updated with possibly a zero value
assignment. That looks like an unnecessary maintenance burden. Should
we just drop all those zero value assignments from there? If there's
any reason to have those assignments there, should we move the code to
allocate RelOptInfo and assign zero values to a separate function and
call it from those two functions? fetch_upper_rel() also has those
kinds of assignments, but they are far fewer than build_*_rel().

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-02-06 04:52:50 Re: Provide list of subscriptions and publications in psql's completion
Previous Message Kouhei Kaigai 2017-02-06 04:42:10 Re: ParallelFinish-hook of FDW/CSP (Re: Steps inside ExecEndGather)