Hi all.<br><br>I use PG 8.1.8 and PostGIS 1.1.1<br>vka1=# select version();<br> version<br>-----------------------------------------------------------------------------------------------------------------
<br> PostgreSQL 8.1.8 on x86_64-pc-linux-gnu, compiled by GCC cc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)<br><br>vka1=# select postgis_full_version();<br> postgis_full_version<br>----------------------------------------------------------------------------------
<br> POSTGIS="1.1.1" GEOS="2.2.3-CAPI-1.1.1" PROJ="Rel. 4.4.9, 29 Oct 2004" USE_STATS<br><br>I develop application for loading geodata to database. In separate transaction the application inserts the data in separate table that created dynamically when transaction started. All tables has equal structure.
<br><br>Geodata has simple and similar structure (field geometry): POLYGON((x1 y1, x2 y2, x3 y3, x4 y4, x1 y1))<br>
For loading geodata I use INSERT into <TABLE_NAME> .... via LIBPQ.<br>
In big loop I call PQexec(conn, query).<br>
<br>
I found *VERY* strange problem: speed of the loading process is slow
down (first 10000 objects are loaded in 69792 ms and last 10000 objects
in 123737 ms). And futhermore, if I do NOT close current session but
start new transaction, the first 10000 objects will be loaded in 192279
ms and last 10000 objects in 251742 ms. And so on!! :-(<br>
<br>
But if I drop the trigger speed of loading process is NOT slow down.<br>
<br>
Who can explain me what I do incorrect?<br>
<br>
Thanks in advance<br>
<br>
Sergey Karin<br>
<br>=======================================<br>================code===================<br>=======================================<br>create table <TABLE_NAME> (<br> GID SERIAL not null,
<br> GEOM_ORDER INT4 not null default 0,<br> ZOOMABLE BOOL not null default false,<br> GEOM GEOMETRY <br> constraint <TABLE_NAME_GID> primary key (GID),
<br> );<br><br>create index <TABLE_NAME_GEOM_INDEX> on <TABLE_NAME> using gist ( geom gist_geometry_ops );<br>create trigger trgOInsert <br> before insert or update <br> on <TABLE_NAME>
<br> for each row <br> execute procedure oInsertCheck('GEOMETRYCOLLECTION', 0);<br><br>create or replace function oInsertCheck() returns trigger as'<br>declare<br> g_isvalid boolean;
<br> iSrid int4;<br> geomType varchar;<br>begin<br> <br> if(new.geom isnull) then<br> new.geom := geomFromText(\'GEOMETRYCOLLECTION(EMPTY)\');<br> end if;<br> if(new.geom_order isnull) then
<br> new.geom_order := 0;<br> end if;<br> <br> select isvalid(new.geom) into g_isvalid;<br> if(g_isvalid isnull) then<br> return NULL;<br> end if;<br> <br> geomType := TG_ARGV[TG_NARGS-2];
<br> iSrid := TG_ARGV[TG_NARGS-1];<br> <br> if(upper(geomType) = \'GEOMETRYCOLLECTION\') then<br> new.geom := force_collection(new.geom); <br> end if;<br> <br> new.geom := setSrid(
new.geom, iSrid);<br> <br> return new;<br>end<br>'language 'plpgsql' security definer;<br><br>=================end of code==========================<br><br>