<div dir="ltr"><div><div><div><div>Create or updte a spatial index in a table is a danger operation ..<br>So in postgis it is availabale only to user with write grant.<br><br></div>QGIS is unable to understand if a connection is readonly or write enable so try to do an automatic update<br>
is a trouble-matic operation if a table was open from a read-only user.<br><br></div>Another question is why it should be complex for an user to create an index ?<br><br></div>A second question is what kind of index ?<br>
</div><div>On postgis is possible to do more than one index.<br><br></div><div>A table could have more than one geometry and every one could have a spatial index or not.<br></div><div>But an index is a space consuming and often the index is needed on 1 only geometry field menawhile the other <br>
geometry field are only for special uses.<br></div><div>To do always automatically a spatial index on every geometry filed is really a not useful operation in these use-case.<br><br></div><div>A.<br></div><div><div><div><div>
<br></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-27 15:04 GMT+01:00 Etienne Tourigny <span dir="ltr"><<a href="mailto:etourigny.dev@gmail.com" target="_blank">etourigny.dev@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="">On Thu, Feb 27, 2014 at 10:56 AM, Etienne Tourigny <span dir="ltr"><<a href="mailto:etourigny.dev@gmail.com" target="_blank">etourigny.dev@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">That's a python plugin (ftools), so it may not be available to everyone. <div>

<br></div><div>Better to do it natively (in the data provider) doing something like <span style="font-size:12px;background-color:rgb(251,252,253);font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif"> </span>OGR_DS_ExecuteSQL("<span>CREATE SPATIAL INDEX ON tablename [DEPTH N]</span>") - untested</div>

</div></blockquote><div><br></div></div><div>there is already a function QgsOgrProvider::createSpatialIndex() (for shapefiles only) which  is called by QgsOgrProvider::syncToDisc() if the spatial index already exists.</div>
<div class=""><div>
 </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">
<div><br></div><div>I think it's a great idea to do this automatically with large ogr data sources</div><div><br></div><div>as you said you should probably ask the gdal-dev list about which drivers support spatial index creation an automatic update.</div>


<div><br></div><div>cheers</div><span><font color="#888888"><div>Etienne</div></font></span></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Thu, Feb 27, 2014 at 7:51 AM, kimaidou <span dir="ltr"><<a href="mailto:kimaidou@gmail.com" target="_blank">kimaidou@gmail.com</a>></span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">Hi<br><div>
<div class="gmail_extra"><br><div class="gmail_quote">2014-02-27 11:14 GMT+01:00 Andrea Peri <span dir="ltr"><<a href="mailto:aperi2007@gmail.com" target="_blank">aperi2007@gmail.com</a>></span>:<div>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>I guess more better is to use this extremely simple batch and create all the index in one step only.<br>

sing the gdal/ogr from osgeo4w.<br>

<br><a href="http://trac.osgeo.org/gdal/wiki/BatchCreationIndexesForShapefilesOnDOS" target="_blank">http://trac.osgeo.org/gdal/wiki/BatchCreationIndexesForShapefilesOnDOS</a><br>
<br></div>Regards,<br></div><br></blockquote><div><br><br></div></div><div> As I said, I am thinking of non power users. They surely won't create nor use such a batch file, even if it is simple. I know there is also the great tool Vector / Data management tools / Create Spatial Index, which can create one for all layers in one step. But users do not use it : they do no know it exists, or they know but forget to use it.<br>



</div></div><br></div></div></div>
<br></div></div><div>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></div></blockquote></div><br></div>
</blockquote></div></div><br></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>-----------------<br>Andrea Peri<br>. . . . . . . . . <br>qwerty àèìòù<br>-----------------<br>
</div>