邮政编码范围查询优化

时间:2015-05-06 11:03:55

标签: mysql zipcode

我试图通过输入邮政编码来建立搜索位置。

我使用了本指南https://translate.google.de/translate?sl=de&tl=en&js=y&prev=_t&hl=de&ie=UTF-8&u=http%3A%2F%2Fwww.phpgangsta.de%2Feine-plz-umkreissuche-in-php&edit-text=

搜索将尝试通过2个国家/地区查找邮政编码。 在特定搜索中,我收到此错误:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 13 bytes) in

这是查询:

SELECT
dest.plz,
dest.ort,
ACOS(
SIN(RADIANS(src.lat)) * SIN(RADIANS(dest.lat))
+ COS(RADIANS(src.lat)) * COS(RADIANS(dest.lat))
* COS(RADIANS(src.lon) - RADIANS(dest.lon))
) * 6380 AS distance
FROM geodb_data dest
CROSS JOIN geodb_data src
WHERE src.plz = $zipEncode
AND dest.plz <> src.plz
HAVING distance < $distanceEncode
ORDER BY distance;

我的问题是,如何优化此查询?

0 个答案:

没有答案