Re: partitioning - changing a slot's descriptor is expensive

Поиск
Список
Период
Сортировка
От Amit Langote
Тема Re: partitioning - changing a slot's descriptor is expensive
Дата
Msg-id e4f9d743-cd4b-efb0-7574-da21d86a7f36@lab.ntt.co.jp
обсуждение исходный текст
Ответ на Re: partitioning - changing a slot's descriptor is expensive  (Andres Freund <andres@anarazel.de>)
Ответы Re: partitioning - changing a slot's descriptor is expensive  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Re: partitioning - changing a slot's descriptor is expensive  (Amit Khandekar <amitdkhan.pg@gmail.com>)
Список pgsql-hackers
On 2018/06/29 14:59, Andres Freund wrote:
> On 2018-06-29 11:20:53 +0530, Amit Khandekar wrote:
>> On 27 June 2018 at 18:33, Ashutosh Bapat
>>> But I am worried that the code will have to create thousand slots if
>>> there are thousand partitions. I think we will need to see how much
>>> effect that has.
>>
>> I agree that it does not make sense to create as many slots, if at all
>> we go by this approach. Suppose the partitioned table is the only one
>> having different tuple descriptor, and rest of the partitions have
>> same tuple descriptor. In that case, keep track of unique descriptors,
>> and allocate a slot per unique descriptor.
> 
> Why? Compared to the rest of the structures created, a slot is not
> particularly expensive? I don't see what you're optimizing here.

What I'm thinking of doing is something that's inspired by one of the
things that David Rowley proposes in his patch for PG 12 to remove
inefficiencies in the tuple routing code [1].

Instead of a single TupleTableSlot attached at partition_tuple_slot, we
allocate an array of TupleTableSlot pointers of same length as the number
of partitions, as you mentioned upthread.  We then call
MakeTupleTableSlot() only if a partition needs it and pass it the
partition's TupleDesc.  Allocated slots are remembered in a list.
ExecDropSingleTupleTableSlot is then called on those allocated slots when
the plan ends.  Note that the array of slots is not allocated if none of
the partitions affected by a given query (or copy) needed to convert tuples.

Other issues that you mentioned, such as needless heap_tuple_deform/form
being invoked, seem less localized (to me) than this particular issue, so
I created a patch for just this, which is attached with this email.  I'm
thinking about how to fix the other issues, but will need a bit more time.

Thanks,
Amit

[1]
https://www.postgresql.org/message-id/CAKJS1f_1RJyFquuCKRFHTdcXqoPX-PYqAd7nz=GVBwvGh4a6xA@mail.gmail.com

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ashutosh Bapat
Дата:
Сообщение: Re: partitioning - changing a slot's descriptor is expensive
Следующее
От: Rajkumar Raghuwanshi
Дата:
Сообщение: Re: Server crashed with "TRAP: unrecognized TOAST vartag("1", File:"heaptuple.c", Line: 1490)"