Discussing with a developer, it turns out there's an option named <b>Use estimated table metadata</b> in the PostGIS connection properties. Using that solved it for me as it adds <b>LIMIT 100</b> to the query.<div><br>

</div><div>So the fix is there, it's just kind of buried.</div><div><br></div><div>And, again, this is for a view, and it appears there's no way to know what a kind of geometry is in a view's geometry column without inspecting it.<br>

<div><br></div><div>Aren<br><br><div class="gmail_quote">On Sun, Jan 30, 2011 at 2:03 PM, Ivan Mincik <span dir="ltr"><<a href="mailto:ivan.mincik@gmail.com">ivan.mincik@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5">On Sun, Jan 30, 2011 at 4:59 PM, Aren Cambre <<a href="mailto:aren@arencambre.com">aren@arencambre.com</a>> wrote:<br>
> I noticed this really inefficient query when QGIS was importing a Postgis<br>
> layer:<br>
> select distinct case when geometrytype("the_geom") IN ('POINT','MULTIPOINT')<br>
> THEN 'POINT' when geometrytype("the_geom") IN<br>
> ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING' when<br>
> geometrytype("the_geom") IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON' end<br>
> from [databaseGoesHere]<br>
> That surprised me because QGIS should already know the geometrytype through<br>
> the geomerty_columns table.<br>
> Is this really QGIS's fault, or did Postgis cause/require this? Want to make<br>
> sure before I file a bug report.<br>
<br>
</div></div>Hi, which QGIS version do You use ?<br>
Has all You tables and views valid records in 'geometry_columns' ? If<br>
not, tables/views which are not present in 'geometry_colums' are<br>
queried by query You are talking about. If just one of them is big, or<br>
time expensive view, each database connect will take very long time.<br>
<br>
In current trunk (and I do not remember how many versions back), there<br>
is option 'Only look in the geometry_columns tables' which can help<br>
You.<br>
<font color="#888888"><br>
Ivan<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div></div>