I have a simple table like so

CREATE TABLE points (
id INTEGER PRIMARY KEY,
lon REAL,
lat REAL,
tile INTEGER
);

It has about 13.25 million rows. I want to be able to return rows given a 
bounding box (min_lon, min_lat, max_lon, max_lat). Is the following the right 
strategy?

CREATE VIRTUAL TABLE points_rtree USING rtree (
id, min_lon, min_lat, max_lon, max_lat
);

and then querying like so

SELECT p.id, tile 
FROM points p JOIN points_rtree pr ON p.id = pr.id 
WHERE min_lon >= -91 AND max_lon <= -89 AND min_lat >= 43 AND max_lat <= 45;



-- 
Puneet Kishor 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to