[Qgis-developer] very slow on creating a new empty spatialite db

a.furieri at lqt.it a.furieri at lqt.it
Fri Aug 7 08:20:23 PDT 2015


On Fri, 07 Aug 2015 16:43:11 +0200, Ing. Pierluigi De Rosa wrote:
> Dear all,
>
> I'm experiencing than when I create a new empty spatialite from qgis 
> it
> takes long time to do it.
> ---------------- <snip> -------------
> sql = 'SELECT InitSpatialMetadata()'
>

Hi Pierluigi,

InitSpatialMetadata() will insert about 5,000 rows into the
spatial_ref_sys table.
SQLite is a full ACID DBMS, so performing so many INSERTs
outside a TRANSACTION will certainly be a very slow operation.

solution #1:
-----------
sql = 'BEGIN; SELECT InitSpatialMetadata(); COMMIT;'

solution #2:
------------
sql = 'SELECT InitSpatialMetadata(1);'

both solutions have the same identical effect:
in the first case you'll explicitly define a Transaction
in your own SQL code.
in the second case by passing to InitSpatialMetadata()
a TRUE argument you'll authorize this function to silently
handle an internal Transaction.

bye Sandro


More information about the Qgis-developer mailing list