From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | "Ma, Marcus" <marcjma(at)amazon(dot)com> |
Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Retrieving unused tuple attributes in ExecScan |
Date: | 2022-06-27 19:09:46 |
Message-ID: | 20220627190946.6b7xekyibfvkzvkn@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2022-06-27 19:00:44 +0000, Ma, Marcus wrote:
> If I understand correctly, when a Sequential Scan takes place, the ExecScan function (located in executor/execScan.c) does not retrieve all attributes per tuple in the TupleTableSlot and only retrieves the necessary attribute. So for example, let’s imagine we have a table t1 with 3 number fields, c1, c2, and c3. So in the command:
>
> Select * from t1 where t1.c1 > 500;
>
> The returned TupleTableSlot will have its field of tts_values in the form (X, 0, 0), where X is the real value of t1.c1 but the fields of c2 and c3 are not actually retrieved because they aren’t used. Similarly, for the command:
>
> Select * from t1;
>
> The TupleTableSlot will always return the values of (0, 0, 0) because no
> comparisons are necessary. I am working on code where I’ll need access to
> attributes that aren’t listed in any qualification – what code should I
> change in execScan, or nodeSeqScan to be able to retrieve any attribute of a
> tuple? Basically, being able to make execScan return (X, Y, Z) instead of
> (0, 0, 0) even if the command doesn’t use any attribute comparisons.
You'll need to tell the planner that those columns are needed. It's not just
seqscans that otherwise will discard / not compute values.
Where exactly do you need those columns and why?
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Ma, Marcus | 2022-06-27 19:29:34 | Re: Retrieving unused tuple attributes in ExecScan |
Previous Message | Jacob Champion | 2022-06-27 19:05:57 | Re: [PoC] Let libpq reject unexpected authentication requests |