[postgis-users] Benshmark postgis

Arnaud Vandecasteele arnaud.sig at gmail.com
Thu Nov 25 09:16:12 PST 2010


Hi all,

I've to do a quick benchmark  of postgis. The case is to check if a
point is inside (or not) a polygon.
To do so, I've uploaded in my database a big shapefile which contains
all the world's countries.
After that I've made a simple stored function [1]. This one, take two
arguments :
1 - The number of points to check
2 - The number of polygon to check

Then I run the query and i change the number of iterations or the
number of feature.

Do you think it's a good way to have some pertinents results ?


Best regards

Arnaud


[1]
-- Function: random_poi(integer, integer)

-- DROP FUNCTION random_poi(integer, integer);

CREATE OR REPLACE FUNCTION random_poi(integer, integer)
  RETURNS void AS
$BODY$
DECLARE
	iteration alias for $1;
	nb_feat alias for $2;
	pt_x numeric;
	pt_y numeric;
	geom_poi geometry;
	i int := 0;
BEGIN
	WHILE i < iteration LOOP
		i := i + 1;
		-- CREATE RANDOM POSITION
		pt_x := random()*100;
		pt_y := random()*100;
		-- CREATE RANDOM GEOM POI
		geom_poi := ST_GeometryFromText(text 'POINT('||pt_x||' '||pt_y||')');
		PERFORM ST_CONTAINS(geom_poi, the_geom) FROM world_poly LIMIT nb_feat;					
	END LOOP;	
	return;	
END;
$BODY$
  LANGUAGE 'plpgsql' IMMUTABLE STRICT
  COST 100;
ALTER FUNCTION random_poi(integer, integer) OWNER TO postgres;



More information about the postgis-users mailing list