>>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?


Tom, I make some test with this ugly patch which makes structure giststate 
static (pls, don't commit this patch :) ).

Test:
1. install contrib/btree_gist
2. create 'sql.cmd' file contains:
DROP TABLE tbl;
BEGIN TRANSACTION;
CREATE TABLE tbl (v INT);
CREATE INDEX tblidx ON tbl USING GIST (v);
COPY tbl FROM '/tmp/data';
END TRANSACTION;
3. create /tmp/data with 10000 random values.

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.


-- 
Teodor Sigaev
[EMAIL PROTECTED]

ugly_patch.gz


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply via email to