Re: index access method documentation light on details on ii_AmCache

2023-09-15 Thread Seebs
On Thu, 14 Sep 2023 10:06:03 -0300
"Euler Taveira"  wrote:

> AFAICS there isn't a chapter dedicated to memory contexts in the
> documentation. Did you check the README that I pointed out in the
> previous email? Most of the developer information is available in
> README files in the source code. Server Programming and Internals
> contain useful information for Postgres hackers too.

... I did not check that out, I will go look at the readmes. The
documentation had enough documentation on things like "here's the list
of functions to implement" that I hadn't gone looking for other
documentation.

Thanks!

-s




Re: index access method documentation light on details on ii_AmCache

2023-09-14 Thread Seebs
On Wed, 13 Sep 2023 15:48:41 -0300
"Euler Taveira"  wrote:

> Unless you change it, ii_Context is CurrentMemoryContext (see
> makeIndexInfo). Hence, your AM state information is freed when the
> current memory context is freed.

A thing I am now wondering:

Is there anything in the postgresql documentation which explains this,
or says when a given memory context will be freed? Like, is the
ii_Context there for the lifetime of the index? For the lifetime of the
query? For the lifetime of a single insert operation?

I've found a reference to it in a third-party blog post, but I actually
can't find anything in the docs explaining memory contexts, and a bit
of experimenting makes me think they are doing things that aren't
obvious to me. For instance, I tried *not* deleting a memory context
when done with it, then looping doing a query which tried to create and
populate it, and... memory usage did not go up. Making me think that
maybe it gets reused? Or maybe it's implicitly deleted because it had
a parent context?

-s