Re: stack usage in toast_insert_or_update() - Mailing list pgsql-hackers

From Pavan Deolasee
Subject Re: stack usage in toast_insert_or_update()
Date
Msg-id 2e78013d0701302148s440b8849kae33c6ce4b5fb855@mail.gmail.com
Whole thread Raw
In response to Re: stack usage in toast_insert_or_update()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: stack usage in toast_insert_or_update()
List pgsql-hackers

On 1/30/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Pavan Deolasee" <pavan.deolasee@gmail.com> writes:
> The stack usage for toast_insert_or_update() may run into several KBs since
> the MaxHeapAttributeNumber is set to a very large value of 1600. The usage
> could anywhere between 28K to 48K depending on alignment and whether its a
> 32-bit or a 64-bit machine.

So?  The routine is not re-entrant so I don't see that the stack space
is a big problem.  It's coded that way to avoid palloc/pfree cycles...

I always thought that it would be costlier to have a repeated stack allocation/deallocation
of many KBs than dynamically allocating a small percentage of that. But I might be wrong.
In fact, a small test I ran showed that mallloc/free is more costly. So may be are
good.
 
Btw, I noticed that the toast_insert_or_update() is re-entrant. toast_save_datum()
calls simple_heap_insert() which somewhere down the line calls
toast_insert_or_update() again. It looks a bit surprising, haven't look into detail
though.

Thanks,
Pavan

--

EnterpriseDB     http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PL/pgSQL RENAME functionality in TODOs
Next
From: Tom Lane
Date:
Subject: Re: stack usage in toast_insert_or_update()