我有一个MySQL数据库.我将家庭存储在数据库中,并且只对数据库执行1次查询,但我需要以超快的速度执行此查询,并且这将返回方形框内的所有家庭地理纬度和经度.
SELECT * FROM homes
WHERE geolat BETWEEN ??? AND ???
AND geolng BETWEEN ??? AND ???
Run Code Online (Sandbox Code Playgroud)
如何存储我的地理数据的最佳方式,以便我可以执行此查询显示地理定位框中的所有家庭最快?
基本上:
如果有帮助,我在下面包含我的数据库表模式:
CREATE TABLE IF NOT EXISTS `homes` (
`home_id` int(10) unsigned NOT NULL auto_increment,
`address` varchar(128) collate utf8_unicode_ci NOT NULL,
`city` varchar(64) collate utf8_unicode_ci NOT NULL,
`state` varchar(2) collate utf8_unicode_ci NOT NULL,
`zip` mediumint(8) unsigned NOT NULL,
`price` mediumint(8) unsigned NOT NULL,
`sqft` smallint(5) unsigned NOT NULL,
`year_built` smallint(5) unsigned NOT NULL,
`geolat` decimal(10,6) default NULL,
`geolng` …Run Code Online (Sandbox Code Playgroud)