[gdal-dev] Review of ogr2ogr SQL queries

Even Rouault even.rouault at spatialys.com
Sat Sep 19 05:08:08 PDT 2015


Pekka,
> 
> I just wonder if it possible to review which kind of SQL queries ogr2ogr is
> doing.

With a debug build of GDAL and "--debug on" added on the ogr2ogr command line, 
you should be able to see the queries.
Otherwise you could have a look at the PostgreSQL logs

> 
> My problem: I'm exporting data from PostGIS to SQlite and some of the
> queries are slow. So, I'm not sure if my indexes are perfect in PostGIS
> side. Should be, but you never know.
> 
> My export query includes -clipsrc <from PostGIS layer>. Is ogr2ogr building
> one huge SQL query to PostGIS or will it first get clip
> polygon/multipolygons from -clipsrc and then send that again to PostGIS?

Ah, from what I see in the code, it appears that -clipsrc does only client-
side clipping. You should probably combine it with -spat so that server side 
filtering happens and reduce the number of features that are received on the 
client side. Not sure why it isn't done automatically: developer lazyness I 
guess ;-)

Even

> 
> Rgs,
> 
> Pekka
> 
> Pekka Sarkola
> Gispo Oy
> pekka.sarkola at gispo.fi   - GSM +358 40 725 2042
> www.gispo.fi – www.paikkatieto.com

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list