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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题