Re: Some questions about the array.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yury Zhuravlev <u(dot)zhuravlev(at)postgrespro(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Some questions about the array.
Date: 2015-12-23 02:15:03
Message-ID: 4475.1450836903@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yury Zhuravlev <u(dot)zhuravlev(at)postgrespro(dot)ru> writes:
> New patch version in attachment.

I've committed this with a number of revisions, mostly but not entirely
cosmetic. Worthy of note:

* I did not like the way you were inserting the replacement subscript
values:

+ arrays = (AnyArrayType *)DatumGetArrayTypeP(array_source);
+ indexexpr = AARR_LBOUND(arrays)[i] + AARR_DIMS(arrays)[i] - 1;

If the source array is toasted, this causes an extra detoast operation
for *each* omitted subscript. That could be pretty high overhead for
a large array. The best way to avoid that is to postpone the actual
substitution of the replacement subscript values into array_get_slice
and array_set_slice; which complicates their APIs a bit more, but those
were pretty long argument lists already.

* Having done that, there was no very good reason for the blanket
prohibition on using omitted subscripts in the slice-set case. We only
really need to fail if we're constructing the array from scratch, when
we don't have any existing subscript limits to substitute.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2015-12-23 02:28:39 pgbench --latency-limit option
Previous Message Tom Lane 2015-12-23 02:09:20 Re: Possible marginally-incompatible change to array subscripting