I find solution after few days :)
Sorry for my english --'
public.pgr_createtopology
call the function public._pgr_pointToId
and this is the one that takes too long to complete when the vertice_pgr tale is full enough (~15 MB) on my server.
I improved this one and EUREKA it works!
I create this:
CREATE OR REPLACE FUNCTION public._pgr_pointtoid2(point geometry, tolerance double precision, vertname text, srid integer)
RETURNS bigint
LANGUAGE plpgsql
STRICT
AS $function$
DECLARE
rec record;
pid bigint;
BEGIN
EXECUTE '
with w1 as (
select ST_GeomFromText(ST_AsText(' || quote_literal(point::text) ||'),' || srid || ') as geom
)
SELECT id,ST_Distance(the_geom,geom) as d
FROM '||_pgr_quote_ident(vertname)||'
inner join w1 on ST_DWithin(w1.geom,the_geom,' || tolerance||')
ORDER BY d
LIMIT 1' INTO rec ;
IF rec.id IS NOT NULL THEN
pid := rec.id;
ELSE
execute 'INSERT INTO '||_pgr_quote_ident(vertname)||' (the_geom) VALUES ('||quote_literal(point::text)||')';
pid := lastval();
END IF;
RETURN pid;
END;
$function$
;
AND i change the public.pgr_createtopology at line 208. Now i call the new function.
source_id := _pgr_pointToId2(points.source, tolerance,vertname,srid);
target_id := _pgr_pointToId2(points.target, tolerance,vertname,srid);