douzizang7783 2015-09-14 14:00
浏览 22
已采纳

更好的想法如何从数据库中获取大量的MySql数据

I have a big database with a lot of adresses, for exampte like this (here as json):

{"id":"1","desc":"Frankie Johnnie & Luigo Too","address":"939 W El Camino Real, Mountain View, CA","lat":"37.386337","lng":"-122.085823"}

I get this data with a simple MySql - Statement:

'Select * from datatable'

And with the answer of this I create the json statements. The Problem is that every data get out of the table and when the database gets bigge, I think that the request takes some time. I don't have any idea how to better select the data. I Need all Data out of teh db to create a map.

Is there a better solution to create not so much traffic? Or is this request not so intensive and don't create so much traffic?

Thanks!

  • 写回答

1条回答 默认 最新

  • dpca4790 2015-09-14 14:13
    关注

    If you create a map you should only get data to draw onto the map, try something like:

    SELECT * FROM datatable 
        WHERE lat > 20 
        AND lat < 40
        AND lng > -140
        AND lng < -100;
    

    Of course this is just an example, you should calculate latitude and longitude limits based on the area you are presenting on the map. Make sure to take into account wraparounds and if you're showing a big enough area of the globe than a square might not be the best match, if you google around there are multiple ways to get proper geodata limitations for anything you want.

    If this is not enough you could also narrow it down based on other principles, that is a partial match on description or address.

    SELECT * FROM datatable 
        WHERE lat > 20 
        AND lat < 40
        AND lng > -140
        AND lng < -100
        AND desc LIKE '%Frankie%';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失