Re: PATCH: CreateComments: use explicit indexing for ``values''

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: richhguard-monotone <richhguard-monotone(at)yahoo(dot)co(dot)uk>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: CreateComments: use explicit indexing for ``values''
Date: 2011-06-14 14:52:42
Message-ID: 1308062890-sup-589@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Excerpts from Tom Lane's message of mar jun 14 10:30:28 -0400 2011:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Excerpts from richhguard-monotone's message of lun jun 13 16:10:17 -0400 2011:
> >> Do you have any advice of how to handle the inner loops, such as those initializing ``stakindN''. The entries before can be handled just like in this patch, by using the symbolic constants.
>
> > Based on Tom's comments, I'd submit the patch without that bit, at least
> > as a first step.
>
> He already did no?

I don't see the patch attached anywhere ...

> I did think of a possible way to rewrite update_attstats: instead of
>
> for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
> {
> values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */
> }
>
> do
>
> for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
> {
> values[Anum_pg_statistic_staop1 - 1 + k] = ObjectIdGetDatum(stats->staop[k]);
> }
>
> etc. However, it's not clear to me whether this is really an
> improvement. Opinions?

I guess the other option is

i = Anum_pg_statistic_staop1 - 1;
for (k = 0; k < STATISTIC_NUM_SLOTS; k++)
{
values[i++] = ObjectIdGetDatum(stats->staop[k]);
}

(I also tried moving the i initialization to the "for" first arg, but it
seems better this way)

Not sure what's better.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Cédric Villemain 2011-06-14 14:52:45 Re: Re: patch review : Add ability to constrain backend temporary file space
Previous Message Robert Haas 2011-06-14 14:50:43 Re: PATCH: CreateComments: use explicit indexing for ``values''