<div dir="ltr">Hi Alexandre,<div>and thanks for the feedback</div><div><br></div><div>I'm sorry but I don't understand the 2 solutions you advised.</div><div><br></div><div>Let's see if I can explain my case better. </div><div>I am using SqlServer and I set up a test project including that view and a normal spatial table.</div><div>Looking at the initialization queries in SQLServer profiler, I noticed that both entities run the same queries. But if the spatial_index_tessellations lookup query returns no data, then QGIS tries to retrieve the extent with a full table scan.</div><div><br></div><div>In order the queries are:</div><div>1) get the computed columns (almost useless for me)</div><div>SELECT name FROM sys.columns WHERE is_computed = 1 AND object_id = xxx</div><div> <br></div><div>2) get columns metadata (in some cases useless for me)</div><div>exec sp_columns @table_name = xxx</div><div><br></div><div>3) get table pks (useless for me)</div><div>exec sp_pkeys @table_name = xxx<br></div><div><br></div><div>4) get extent from index</div><div>SELECT min(bounding_box_xmin), min(bounding_box_ymin), max(bounding_box_xmax), max(bounding_box_ymax) FROM sys.spatial_index_tessellations WHERE object_id = xxx</div><div> <br></div><div>5) if 4 returns no data, then compute the extent from full scan (2 queries)</div><div>5-1) Compute a binary checksum (????? and why 42?)</div><div><br></div><div>select min([SHAPE].STPointN(1).STX), min([SHAPE].STPointN(1).STY), max([SHAPE].STPointN(1).STX), max([SHAPE].STPointN(1).STY), count(*) from xxx WHERE (ABS(CAST((BINARY_CHECKSUM([[OBJECTID]])) as int)) % 100) = 42<br></div><div><br></div><div>5-2) actually compute the extent from full scan</div><div>select min([SHAPE].STPointN(1).STX), min([SHAPE].STPointN(1).STY), max([SHAPE].STPointN(1).STX), max([SHAPE].STPointN(1).STY), count(*) from xxx<br></div></div>