Hi,
I've today investigated a performance issue when opening a huge GeoPackage database (80 GB !)
and getting the extent when it is not stocked in the gpkg_contents table [1]
I tried at first to use a SELECT MIN(minx), MIN(miny), MAX(maxx), MAX(maxy) FROM {rtreeTableName}
but this apparently involves a full table scan, which defeats the purpose. This is even true on recent versions of SQLite
But if you do SELECT 1 FROM {rTreeTableName} WHERE minx < {value} LIMIT 1, this is super fast.
So by implementing a dichotomic search, you can easily determine the minimum/maximum of minx, minx, maxx, maxy
That's what I implemented in GDAL in
https://github.com/OSGeo/gdal/commit/f3276e81274936027803295b32187a59db234eca#diff-a674cfc4ad8bc2d939e8044e5258c577R2394
Could be applied to a Spatialite table of course.
Even
[1]
https://issues.qgis.org/issues/18402
--
Spatialys - Geospatial professional services
http://www.spatialys.com