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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大