Re: More speedups for tuple deformation

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, John Naylor <johncnaylorls(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: More speedups for tuple deformation
Date: 2026-03-16 16:37:56
Message-ID: CAEG8a3+cpoPG9bCX-65Y=VqKrZDvWd2ADLt-1qGyvDAWfL6Qkw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi David and Tender,

On Mon, Mar 16, 2026 at 5:17 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Mon, 16 Mar 2026 at 20:01, Tender Wang <tndrwang(at)gmail(dot)com> wrote:
> > SELECT * FROM t2, t4 RIGHT OUTER JOIN t0 ON t4.c0 WHERE t4.c1 ORDER BY
>
> > server closed the connection unexpectedly
>
> Thanks. Looks like I didn't get the startAttr logic correct in
> nocachegetattr(). Starting by using the attcacheoff of the first NULL
> attribute isn't valid. It should be the attribute prior to that one.
>
> I'm just verifying some code locally now.
>
> David
>
>

The following case is more simpler:

drop table if exists ty;
create table ty(c0 int not null, c1 double precision, c2 int4range);
insert into ty values (1, 1.0, '[1469060470,1895771979)');
insert into ty values(2, null, '[-1973503943,635641598)');
select * from ty order by c2;

In this case, firstNonCachedOffsetAttr is 2 and firstNullAttr is 1.
If we start from 1, the cached offset becomes 8 due to double's
alignby, and deforming int4range from offset 8 will lead to corrupted data.
Therefore, as David said, we should start from the attribute prior
to that one. PFA is a trivial fix, I think we should add the test but
I haven't found a proper regress test file for it.

--
Regards
Junwang Zhao

Attachment Content-Type Size
0001-Fix-startAttr-computation-for-nocache-attribute-fetc.patch application/octet-stream 1.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-03-16 16:46:19 Re: POC: Parallel processing of indexes in autovacuum
Previous Message Nikita Malakhov 2026-03-16 16:30:16 Re: SQL/JSON json_table plan clause