[postgis-users] Inefficient query with QGIS?

Ivan Mincik ivan.mincik at gmail.com
Sun Jan 30 12:03:38 PST 2011


On Sun, Jan 30, 2011 at 4:59 PM, Aren Cambre <aren at arencambre.com> wrote:
> I noticed this really inefficient query when QGIS was importing a Postgis
> layer:
> select distinct case when geometrytype("the_geom") IN ('POINT','MULTIPOINT')
> THEN 'POINT' when geometrytype("the_geom") IN
> ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING' when
> geometrytype("the_geom") IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON' end
> from [databaseGoesHere]
> That surprised me because QGIS should already know the geometrytype through
> the geomerty_columns table.
> Is this really QGIS's fault, or did Postgis cause/require this? Want to make
> sure before I file a bug report.

Hi, which QGIS version do You use ?
Has all You tables and views valid records in 'geometry_columns' ? If
not, tables/views which are not present in 'geometry_colums' are
queried by query You are talking about. If just one of them is big, or
time expensive view, each database connect will take very long time.

In current trunk (and I do not remember how many versions back), there
is option 'Only look in the geometry_columns tables' which can help
You.

Ivan



More information about the postgis-users mailing list