I have the following SQLite table with 198,305 geocoded portuguese postal codes:
CREATE TABLE "pt_postal" (
"code" text NOT N
This query (provided by @OMGPonies):
SELECT *
FROM (
SELECT
"code",
geo(38.73311, -9.138707, "geo_latitude", "geo_longitude") AS "distance"
FROM "pt_postal" WHERE 1 = 1
AND "geo_latitude" BETWEEN 38.7241268076 AND 38.7420931924
AND "geo_longitude" BETWEEN -9.15022289523 AND -9.12719110477
)
WHERE "distance" <= 1
ORDER BY "distance" ASC
LIMIT 2048;
Correctly returns the 873 records, ordered by distance
in ~0.07 seconds.
However, I'm still wondering why SQLite doesn't evaluate geo()
in the WHERE
clause, like MySQL...