Re: Patch for fixing a few memory leaks - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Patch for fixing a few memory leaks
Date
Msg-id 7624.1002410747@sss.pgh.pa.us
Whole thread Raw
In response to Re: Patch for fixing a few memory leaks  (Teodor Sigaev <teodor@stack.net>)
List pgsql-hackers
Teodor Sigaev <teodor@stack.net> writes:
>>> Tom, I want to notice that initGISTstate is called for every inserting
>>> value (for each row). I think it's not good, because this function
>>> called 'fmgr_info' 7 times. 'fmgr_info' call a
>>> 'load_external_function' with execution of sequence search on library
>>> name. Any suggestion?
>> 
>> fmgr_info shouldn't be all that expensive; I'm not really inclined to
>> worry about it.  Do you have evidence to the contrary?

> Result:
> 1. Original gist.c
> % time psql wow < sql.cmd
> psql wow < sql.cmd  0.00s user 0.02s system 0% cpu 7.170 total
> 2. Patched gist.c
> % time psql wow < sql.cmd
> psql wow < sql.cmd  0.02s user 0.00s system 2% cpu 0.699 total

> We can see that calling fmgr_info for 70000 times may be very expensive.

Okay, I've done something about this: fmgr_info results for index
support functions are now kept in the relcache.  I now get roughly
the same timings for loading 10000 tuples into either a plain
btree index or a btree_gist index, rather than a factor-of-7 penalty
for btree_gist as before ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Rene Pijlman
Date:
Subject: Re: anoncvs and CVS link off developers.postgresql.org
Next
From: Brent Verner
Date:
Subject: Re: ALTER RENAME and indexes