qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.43k stars 2.99k forks source link

issue with selecting from sys.spatial_index_tessellations after windows update #50951

Open olegsbogdanovics opened 1 year ago

olegsbogdanovics commented 1 year ago

What is the bug or the crash?

Hello QGIS people!

After last windows update (windows 10, ver. 21H2) Microsoft has something changed in sqlserver provider. This causes extreme slow qgs project loading. Investigated this problem I found that in qgsmssqlprovider.cpp in UpdateStatistics method executing code of selecting from spatial index fails and it causes executing sooo-slooow branch "//If we can't find the extents in the spatial index table just do what we normally do."

trying to reproduce issue in controlled environment, in qgis python console editor I launched script

`from PyQt5 import QtSql connectionString = "DRIVER={SQL SERVER};SERVER=Server21\Udens2;DATABASE=qgis;";

db = QtSql.QSqlDatabase.addDatabase("QODBC"); db.setDatabaseName(connectionString); db.setUserName("blablabla"); db.setPassword("blablabla"); print(db.open()); query = QtSql.QSqlQuery(db); query.exec_( "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 = OBJECT_ID('[dbo].[Pipes]')"); print(db.lastError().text()); while query.next(): print(query.value(0)); print(query.value(1)); print(query.value(2)); print(query.value(3)); `

and the output was: None NULL NULL NULL

Executing this script on non-windows-updated machine output was correct: 653249.0 191085.0 663808.0 203138.0

executing clean SQL in msSqlManager with qgis projec`ts sql credentials is OK.

What is ideas how to deal with this ms bug?

Steps to reproduce the issue

desribed above

Versions

QGIS version 3.16.16-Hannover QGIS code revision f5778a89 Compiled against Qt 5.15.2 Running against Qt 5.15.2 Compiled against GDAL/OGR 3.4.1 Running against GDAL/OGR 3.4.1 Compiled against GEOS 3.10.0-CAPI-1.16.0 Running against GEOS 3.10.0-CAPI-1.16.0 Compiled against SQLite 3.35.2 Running against SQLite 3.35.2 PostgreSQL Client Version 13.0 SpatiaLite Version 5.0.1 QWT Version 6.1.3 QScintilla2 Version 2.11.5 Compiled against PROJ 8.2.1 Running against PROJ Rel. 8.2.1, January 1st, 2022 OS Version Windows Server 2012 R2 Version 6.3 (Build 9600) Active python plugins db_manager; MetaSearch; processing

Supported QGIS version

New profile

Additional context

No response

nicogodet commented 1 year ago

Linked to https://github.com/qgis/QGIS/issues/50865 ?