﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23152	Geodjango spatialite test database initialization very slow on some systems	tomlottermann@…	Doug Goldstein	"While testing some of my gis models, I noticed that the test database setup ran really slowly (about 16 minutes on my harddisk).

I dug a little bit deeper into the code and noticed that the execution of load_spatialite_sql() in contrib/gis/db/spatialite/creation.py went really slowly. To be more precise the line:

{{{
cur.execute(""SELECT InitSpatialMetaData()"")
}}}

I found this issue here:
http://hub.qgis.org/issues/8340

This basically says that the InitSpatialMetaData() command is really slow on some systems, because it executes in many transactions.
One could speed it up by using one of the following solutions:

1. pass 1 to the function. This makes (at least recent versions of spatialite) it execute in a single transaction. I am not really sure for which versions of spatialite this works.
{{{
cur.execute(""SELECT InitSpatialMetaData(1)"")
}}}

2. manually control the transaction:
{{{
cur.execute(""BEGIN ;"")
cur.execute(""SELECT InitSpatialMetaData()"")
cur.execute(""COMMIT ;"")
}}}

For people who have the test database outside the memory this might be a huge problem."	Cleanup/optimization	closed	GIS	dev	Normal	fixed			Accepted	0	0	0	0	0	0
