Re: Use virtual tuple slot for Unique node

From: Denis Smirnov <darthunix(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Borodin Andrey <x4mmm(at)yandex-team(dot)ru>
Subject: Re: Use virtual tuple slot for Unique node
Date: 2023-08-31 17:12:14
Message-ID: 24BC95AF-D6DC-459B-A9B2-41039F9A810C@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have made a small research and found out that though the patch itself is correct (i.e. we can benefit from replacing TTSOpsMinimalTuple with TTSOpsVirtual for the Unique node), my explanation WHY was wrong.

1. We always materialize the new unique tuple in the slot, never mind what type of tuple table slots do we use.
2. But the virtual tuple materialization (tts_virtual_copyslot) have performance benefits over the minimal tuple one (tts_minimal_copyslot):
- tts_minimal_copyslot always allocates zeroed memory with palloc0 (expensive according to the flame graph);
- tts_minimal_copyslot() doesn’t allocate additional memory if the tuples are constructed from the passed by value column (but for the variable-size columns we still need memory allocation);
- if tts_minimal_copyslot() need allocation it doesn’t need to zero the memory;

So as a result we seriously benefit from virtual TTS for the tuples constructed from the fixed-sized columns when get a Unique node in the plan.

> 31 авг. 2023 г., в 10:28, Denis Smirnov <darthunix(at)gmail(dot)com> написал(а):
>
> It looks like my patch was not analyzed by the hackers mailing list due to incorrect mime type, so I duplicate it here.
> <v2-use-virtual-slots-for-unique-node.patch.txt>
>
>> 31 авг. 2023 г., в 10:06, Denis Smirnov <darthunix(at)gmail(dot)com> написал(а):
>>
>> <v2-use-virtual-slots-for-unique-node.patch.txt>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dagfinn Ilmari Mannsåker 2023-08-31 17:23:54 Re: Replace some cstring_to_text to cstring_to_text_with_len
Previous Message Ranier Vilela 2023-08-31 16:57:24 Re: Replace some cstring_to_text to cstring_to_text_with_len