Greg Mitchell <[EMAIL PROTECTED]> writes: > As far as memory management goes, do I just use hash_create() and assign > that pointer to fn_extra and at the end of the query it will be freed? > Or will it not be freed until this end of the transaction? I'm really > having trouble understanding the memory management issues with Postgres.
You have to be careful that the hashtable is created in the correct "memory context" --- in this case you want it to be in a query-lifespan context, not the short-term (per-tuple-lifespan) context that your function will be called in. The usual procedure for cases like this is to use the context identified by fn_mcxt. src/backend/utils/mmgr/README might make useful reading for you. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match