[gdal-dev] OGR and database filter on spatial extent

Frank Warmerdam warmerdam at pobox.com
Thu Jun 11 12:40:56 EDT 2009


Brent Fraser wrote:
> More performance news...
> Using ogrinfo -> VRT -> ODBC -> SqlServer2000, the query using:
>    <SrcLayer>alta83_v1</SrcLayer>
>     - takes less than 2 seconds
> 
>    <SrcSQL>Select * from alta83_v1</SrcSQL>
>     - a very simple select, logically equivalent to the above
>     - takes 30 seconds (!)
> 
>> From the debug messages below, it seems that the spatial filter is not 
>> passed to the database server if a <SrcSQL> is included in the VRT.  
>> Not too surprising given the difficultly of parsing a SELECT statement 
>> and rebuilding it with additional clauses, but we should mention the 
>> order of magnitude performance hit in the doc.
> 
> And I'm not sure why ogr seems to execute the SQL three times...

Brent,

Any time you provide your own SQL it will be executed unaltered.  The
spatial and attribute filters are only automatically built into the
select statement when the select statement is constructed internally
by OGR.

OGR makes *no attempt at all* to interprete provided SQL (via ExecuteSQL()
or <SrcSQL>.  So it has no idea what tables it relates to or how any
restrictions could be added.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list