douyou2234 2013-02-19 08:44
浏览 7
已采纳

在内存中持有一张大地图,还是执行多个sql调用?

I am coming from a background of web development but now am building my first server application in Go and have some questions.

The application will get a lot of http requests containing a string that I need to lookup and validate, basically if the string exists in database it is valid.

Normally I do a new SQL query at every incoming http request, but are there better to just do one big SQL request at init and load all the 50.000 strings into a map in memory? And use that for fast lookup?

  • 写回答

1条回答 默认 最新

  • dongxin1999 2013-02-19 12:14
    关注

    It depends on the string size and the amount of strings.

    If they fit in memory just fine go for memory mapping them, else query the DB.

    PS: This is not really a go question, neither does it have a definitive answer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想用@vueuse 把项目动态改成深色主题,localStorge里面的vueuse-color-scheme一开始就给我改成了dark,不知道什么原因(相关搜索:背景颜色)
  • ¥20 OPENVPN连接问题
  • ¥15 flask实现搜索框访问数据库
  • ¥15 mrk3399刷完安卓11后投屏调试只能显示一个设备
  • ¥100 如何用js写一个游戏云存档
  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计