IntroDuring last week several interesting things happened, and the final result was a massive optimization of the R*Tree module.This is a strategic component of SpatiaLite because it's the corner stone of the Spatial Index implementation, so any improvement in this critical area is surely welcome.
Methodology
|
Tests based on Point Geometries | ||||
---|---|---|---|---|
This dataset contains 1,522,752 features, actually corresponding to all House Numbers of Tuscany. | ||||
SQL | Operation | Previous Version | Latest Version | Comments |
CREATE TABLE cp_1_points ( id INTEGER PRIMARY KEY, comune TEXT, indirizzo TEXT, scritta TEXT); SELECT AddGeometryColumn('cp_1_points', 'geom', 3003, 'POINT', 'XY'); SELECT CreateSpatialIndex('cp_1_points', 'geom'); INSERT INTO cp_1_points SELECT id, comune, indirizzo, scritta, geom FROM points; |
|
36 secs | 29 secs | Time reduced by about 20% thanks to the most recent optimizations of the R*Tree module of SQLite. |
CREATE TABLE cp_2_points ( id INTEGER PRIMARY KEY, comune TEXT, indirizzo TEXT, scritta TEXT); SELECT AddGeometryColumn('cp_2_points', 'geom', 3003, 'POINT', 'XY'); INSERT INTO cp_2_points SELECT id, comune, indirizzo, scritta, geom FROM points; SELECT CreateSpatialIndex('cp_2_points', 'geom'); |
|
9 secs | 8 secs | Substantially unchanged |
|
14 secs | 5 secs | An astonishing time reduction of about 65% the brand new Bulk Load support is really fast |
|
DELETE FROM cp_2_points WHERE (id % 4) = 0; |
|
6 secs | 5 secs | Substantially unchanged |
SELECT s.sez2011, Count(*) AS cnt FROM sezcen AS s JOIN cp_1_points AS p ON ( ST_Intersects(p.geom, s.geom) = 1 AND p.id IN (SELECT rowid FROM SpatialIndex WHERE f_table_name = 'cp_1_points' AND search_frame = s.geom)) GROUP BY s.sez2011 ORDER BY cnt DESC; |
|
46 secs | 43 secs | Substantially unchanged |
Tests based on Polygon Geometries | ||||
---|---|---|---|---|
This dataset contains 2,053,985 features, actually corresponding to all Buildings of Tuscany. | ||||
SQL | Operation | Previous Version | Latest Version | Comments |
CREATE TABLE cp_1_polygs ( id INTEGER PRIMARY KEY, uv_id TEXT, edifc_duso TEXT); SELECT AddGeometryColumn('cp_1_polygs', 'geom', 3003, 'POLYGON', 'XY'); SELECT CreateSpatialIndex('cp_1_polygs', 'geom'); INSERT INTO cp_1_polygs SELECT id, uv_id, edifc_duso, geom FROM polygs; |
|
52 secs | 45 secs | Time reduced by about 15% thanks to the most recent optimizations of the R*Tree module of SQLite. |
CREATE TABLE cp_2_polygs ( id INTEGER PRIMARY KEY, uv_id TEXT, edifc_duso TEXT); SELECT AddGeometryColumn('cp_2_polygs', 'geom', 3003, 'POLYGON', 'XY'); INSERT INTO cp_2_polygs SELECT id, uv_id, edifc_duso, geom FROM polygs; SELECT CreateSpatialIndex('cp_2_polygs', 'geom'); |
|
13 secs | 14 secs | Substantially unchanged |
|
20 secs | 8 secs | An astonishing time reduction of about 60% the brand new Bulk Load support is really fast |
|
DELETE FROM cp_2_polygs WHERE (id % 4) = 0; |
|
9 secs | 11 secs | Substantially unchanged |
SELECT s.sez2011, Count(*) AS cnt FROM sezcen AS s JOIN cp_1_polygs AS p ON ( ST_Intersects(p.geom, s.geom) = 1 AND p.id IN (SELECT rowid FROM SpatialIndex WHERE f_table_name = 'cp_1_polygs' AND search_frame = s.geom)) GROUP BY s.sez2011 ORDER BY cnt DESC; |
|
74 secs | 75 secs | Substantially unchanged |
Conclusions
|