#23152 closed Cleanup/optimization (fixed)
Geodjango spatialite test database initialization very slow on some systems
Reported by: | Owned by: | Doug Goldstein | |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:
- 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)")
- 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.
Change History (6)
comment:1 by , 10 years ago
Easy pickings: | unset |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Version: | 1.7-rc-2 → master |
comment:2 by , 10 years ago
I've implemented this and submitted it as part of the following pull request: https://github.com/django/django/pull/3423 Would you accept the same pull request against the 1.7 branch for a future stable bump?
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
From that link, it looks like this is only supported on Spatialite 4.1+ so we may need some conditional logic to avoid breaking older versions.