<div dir="ltr">Hey Steven,<div><br></div><div style>I didn't know about the sys,spatial_index_tesellations table. That might be better to use as it doesn't require the user to do any extra work. Ignore the min_x, min_y stuff I will update the code to use this new table and let you know once it's done.</div>
<div style><br></div><div style>However creating the geometry columns table isn't a bad idea anyway as it will let QGIS find the layers quicker when using the browser, or list layers dialog.</div><div style><br></div>
<div style>Here is a create script:</div><div style><br></div><div style><div>CREATE TABLE [dbo].[geometry_columns](</div><div><span class="" style="white-space:pre"> </span>[f_table_catalog] [varchar](128) NOT NULL,</div>
<div><span class="" style="white-space:pre"> </span>[f_table_schema] [varchar](128) NOT NULL,</div><div><span class="" style="white-space:pre"> </span>[f_table_name] [varchar](256) NOT NULL,</div><div><span class="" style="white-space:pre"> </span>[f_geometry_column] [varchar](256) NOT NULL,</div>
<div><span class="" style="white-space:pre"> </span>[coord_dimension] [int] NOT NULL,</div><div><span class="" style="white-space:pre"> </span>[srid] [int] NOT NULL,</div><div><span class="" style="white-space:pre"> </span>[geometry_type] [varchar](30) NOT NULL,</div>
<div> CONSTRAINT [geometry_columns_pk] PRIMARY KEY CLUSTERED </div><div>(</div><div><span class="" style="white-space:pre"> </span>[f_table_catalog] ASC,</div><div><span class="" style="white-space:pre"> </span>[f_table_schema] ASC,</div>
<div><span class="" style="white-space:pre"> </span>[f_table_name] ASC,</div><div><span class="" style="white-space:pre"> </span>[f_geometry_column] ASC</div><div>)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]</div>
<div>) ON [PRIMARY]</div><div><br></div><div style>This is what mine looks like:</div><div style><br></div><div style><a href="http://i.imgur.com/sMWyvTk.png">http://i.imgur.com/sMWyvTk.png</a><br></div><div style><br></div>
<div style>- Nathan</div><div style><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 1, 2013 at 8:03 PM, Steven Campbell <span dir="ltr"><<a href="mailto:s.campbell@poole.gov.uk" target="_blank">s.campbell@poole.gov.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0">Hi Nathan<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0">Thanks for this info, excuse me for sounding a bit thick here, but as I can’t find any Geometry_columns table in my SQL database, I’m guessing I need to create one as QGIS uses this table to get the extents of the data in SQL, and if it doesn’t exist it works them out on the fly?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0">Do I have to use ogr2ogr to create this table or can I build the table and put in the information myself – or can I use the sys.spatial_index_tesellations table instead as this contains my bounding boxes for x and y?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0">Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0">Steve<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial","sans-serif";color:#0070c0"><u></u> <u></u></span></p><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Nathan Woodrow [mailto:<a href="mailto:madmanwoo@gmail.com" target="_blank">madmanwoo@gmail.com</a>] <br>
<b>Sent:</b> 01 July 2013 00:11<br><b>To:</b> Steven Campbell<br><b>Cc:</b> qgis-user<br><b>Subject:</b> Re: [Qgis-user] OS Mastermap, SQL Server and QGIS<u></u><u></u></span></p></div><div><div class="h5"><p class="MsoNormal">
<u></u> <u></u></p><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Hey Steven,</span><u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">
<span style="font-family:"Arial","sans-serif"">There is a trick you can do to get your layers to load a bit quicker. The thing that takes the most time when loading a layer is calculating the extents, this is done each time the layer is opened and for large layers this can have a pretty big performance hit. So to fix that issue I have made the SQL driver search for a <span style>min_x, min_y, max_x, max_y in the geometry_columns table in order to just read the extent so there is no on the fly calculation needed when the layer is loaded.</span></span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">So your geometry_columns table should look like this:</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><pre><span style><u></u> <u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>f_table_catalog</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style>varchar</span><span style="color:#666600">](</span><span style="color:#006666">128</span><span style="color:#666600">)</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>f_table_schema</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style>varchar</span><span style="color:#666600">](</span><span style="color:#006666">128</span><span style="color:#666600">)</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>f_table_name</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style>varchar</span><span style="color:#666600">](</span><span style="color:#006666">256</span><span style="color:#666600">)</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>f_geometry_column</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style>varchar</span><span style="color:#666600">](</span><span style="color:#006666">256</span><span style="color:#666600">)</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>coord_dimension</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style="color:#000088">int</span><span style="color:#666600">]</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>srid</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style="color:#000088">int</span><span style="color:#666600">]</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>geometry_type</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style>varchar</span><span style="color:#666600">](</span><span style="color:#006666">30</span><span style="color:#666600">)</span><span style> NOT NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>min_x</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style="color:#000088">double</span><span style="color:#666600">]</span><span style> NULL</span><span style="color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>min_y</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style="font-family:"Arial","sans-serif";color:#000088">double</span><span style="font-family:"Arial","sans-serif";color:#666600">]</span><span style="font-family:"Arial","sans-serif""> NULL</span><span style="font-family:"Arial","sans-serif";color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>max_x</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style="font-family:"Arial","sans-serif";color:#000088">double</span><span style="font-family:"Arial","sans-serif";color:#666600">]</span><span style="font-family:"Arial","sans-serif""> NULL</span><span style="font-family:"Arial","sans-serif";color:#666600">,</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="color:#666600">[</span><span style>max_y</span><span style="color:#666600">]</span><span style> </span><span style="color:#666600">[</span><span style="font-family:"Arial","sans-serif";color:#000088">double</span><span style="font-family:"Arial","sans-serif";color:#666600">]</span><span style="font-family:"Arial","sans-serif""> NULL</span><span style><br>
<br><u></u><u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style="font-family:"Arial","sans-serif"">The last four columns are the new ones and you can calculate a rough extents to go in the table like:</span><span style><u></u><u></u></span></pre>
<pre><span style><u></u> <u></u></span></pre><pre><span style><u></u> <u></u></span></pre><pre><span style><u></u> <u></u></span></pre><table border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse"><tbody><tr>
<td style="padding:.75pt .75pt .75pt .75pt"><pre style="text-align:right"><span style="color:#aaaaaa"><u></u> <u></u></span></pre><pre style="text-align:right"><span style="color:#aaaaaa"><u></u> <u></u></span></pre><pre style="text-align:right">
<span style="color:#aaaaaa"><u></u> <u></u></span></pre></td><td style="padding:.75pt .75pt .75pt .75pt"><pre><span style="color:#000088">select</span> min<span style="color:#666600">([</span>ogr_geometry<span style="color:#666600">].</span><span style="color:#660066">STPointN</span><span style="color:#666600">(</span><span style="color:#006666">1</span><span style="color:#666600">).</span>STX<span style="color:#666600">),</span> <br>
<br><u></u><u></u></pre><pre><u></u> <u></u></pre><pre> min<span style="color:#666600">([</span>ogr_geometry<span style="color:#666600">].</span><span style="color:#660066">STPointN</span><span style="color:#666600">(</span><span style="color:#006666">1</span><span style="color:#666600">).</span>STY<span style="color:#666600">),</span> <br>
<br><u></u><u></u></pre><pre><u></u> <u></u></pre><pre> max<span style="color:#666600">([</span>ogr_geometry<span style="color:#666600">].</span><span style="color:#660066">STPointN</span><span style="color:#666600">(</span><span style="color:#006666">1</span><span style="color:#666600">).</span>STX<span style="color:#666600">),</span> <br>
<br><u></u><u></u></pre><pre><u></u> <u></u></pre><pre> max<span style="color:#666600">([</span>ogr_geometry<span style="color:#666600">].</span><span style="color:#660066">STPointN</span><span style="color:#666600">(</span><span style="color:#006666">1</span><span style="color:#666600">).</span>STY<span style="color:#666600">)</span><br>
<br><u></u><u></u></pre><pre><u></u> <u></u></pre><pre>FROM <span style="color:#666600">[</span>TABLE<span style="color:#666600">]</span><u></u><u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre>
<pre><span style="font-family:"Arial","sans-serif"">An entry in the table might look like:</span><u></u><u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre>
<span style="font-family:"Arial","sans-serif""><a href="http://i.imgur.com/gq8DayI.png" target="_blank">http://i.imgur.com/gq8DayI.png</a></span><u></u><u></u></pre>
<pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><span style="font-family:"Arial","sans-serif"">Note: This will only work in the current dev version of QGIS.</span><u></u><u></u></pre>
<pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><span style="font-family:"Arial","sans-serif"">- Nathan</span><u></u><u></u></pre><pre><span style="font-family:"Arial","sans-serif""><br>
<br><u></u><u></u></span></pre></td></tr></tbody></table></div></div><div><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p><div><p class="MsoNormal">On Sat, Jun 29, 2013 at 12:00 AM, Steven Campbell <<a href="mailto:s.campbell@poole.gov.uk" target="_blank">s.campbell@poole.gov.uk</a>> wrote:<u></u><u></u></p>
<div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Hi</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif""> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Does anyone else have significant time delays when trying to open large datasets from a SQL database in QGIS? I have uploaded my Ordnance survey MasterMap data (coverage is the size of an average English County) and although the initial connection to identify the table is very quick, the loading of the table (even when zoomed in to a very big scale (i.e. 1:100) it takes a very long time to open. Once opened the speed is very quick, but getting it to open takes a lot of patience as the application appears to hang.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">On a slightly related topic, if I have connected to one MSSQL database, QGIS then struggles if I try to connect to an additional database, again it just appears to hang for a considerable period of time (30 minutes or more at times), it seems odd especially as the connection to the first SQL database is almost instant....</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Any suggestions as to how I can improve this speed would be greatly appreciated.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Thanks</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Steve Campbell</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">GIS Manager</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Corporate Strategy and Communications</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Borough of Poole | Civic Centre | Poole BH15 2RU</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Tel: 01202 633 362</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Email: <a href="mailto:s.campbell@poole.gov.uk" target="_blank">s.campbell@poole.gov.uk</a></span><u></u><u></u></p><p class="MsoNormal">
<span style="font-family:"Arial","sans-serif"">Website:<a href="http://www.boroughofpoole.com/" target="_blank">www.boroughofpoole.com</a></span><u></u><u></u></p><p class="MsoNormal"><b><i><span style="font-family:"Arial","sans-serif";color:#00b050">Think Green! Please Recycle</span></i></b><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p></div><p>DISCLAIMER:<br>This email and any files transmitted with it may be confidential, legally privileged and protected in law and are intended solely for the use of the individual to whom it is addressed. The copyright in all documentation is the property of the Borough of Poole and this email and any documentation must not be copied or used other than as strictly necessary for the purpose of this email, without prior written consent which may be subject to conditions. Any view or opinions presented are solely those of the author and do not necessarily represent those of the Borough of Poole. The Borough of Poole reserves the right to inspect incoming and outgoing emails. If you have received this email in error please contact the sender by return and confirm that its contents have been destroyed. Telephone enquiries should be directed to the Borough switchboard on 01202 633633.<u></u><u></u></p>
</div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>_______________________________________________<br>Qgis-user mailing list<br><a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div><div>
<div class="h5"><p></p><p>DISCLAIMER:<br>This email and any files transmitted with it may be confidential, legally privileged and protected in law and are intended solely for the use of the individual to whom it is addressed. The copyright in all documentation is the property of the Borough of Poole and this email and any documentation must not be copied or used other than as strictly necessary for the purpose of this email, without prior written consent which may be subject to conditions. Any view or opinions presented are solely those of the author and do not necessarily represent those of the Borough of Poole. The Borough of Poole reserves the right to inspect incoming and outgoing emails. If you have received this email in error please contact the sender by return and confirm that its contents have been destroyed. Telephone enquiries should be directed to the Borough switchboard on 01202 633633.</p>
</div></div></div></blockquote></div><br></div>