[Mapserver-users] mappostgis query

Markus Schnider sp_ml at sourcepole.com
Mon Jul 5 04:52:58 PDT 2004


Hi all

I am perhaps in the wrong  mailing list (it should be perhaps in the developer 
mailinglist ...), but I could not run a query on a layer with more than 
2'000'000 rows. So I tried to change the code. Than I had some results, and 
the results comes faster!

mapserver 4.2 (mappostgis.c)
postgresql 7.4.2
postgis 0.8.1

Why is the following code (see below (1) ):
better than this (2)?

I've tried both versions and version (2) is faster.

(1)
-------------------------------------------------------
		if (strlen(user_srid) == 0)
		{
			sprintf(query_string_0_6,"DECLARE mycursor BINARY CURSOR FOR SELECT %s from 
%s WHERE (%s) and (%s && setSRID( %s,find_srid('','%s','%s') ))", 
columns_wanted,geom_table,layer->filter.string,geom_column,box3d,removeWhite(f_table_name),removeWhite(geom_column));
		}
		else
		{
			sprintf(query_string_0_6,"DECLARE mycursor BINARY CURSOR FOR SELECT %s from 
%s WHERE (%s) and (%s && setSRID( %s,%s) )", 
columns_wanted,geom_table,layer->filter.string,geom_column,box3d,user_srid);

		}
-------------------------------------------------------


(2)
-------------------------------------------------------
		if (strlen(user_srid) == 0)
		{
			sprintf(query_string_0_6,"DECLARE mycursor BINARY CURSOR FOR SELECT %s from 
%s WHERE (%s)",	columns_wanted,geom_table,layer->filter.string);
		}
		else
		{
			sprintf(query_string_0_6,"DECLARE mycursor BINARY CURSOR FOR SELECT %s from 
%s WHERE (%s)", columns_wanted,geom_table,layer->filter.string);

		}
-------------------------------------------------------

Thanks in advance

Markus Schnider



More information about the MapServer-users mailing list