doufangzhang4454 2018-11-20 15:16
浏览 80

为过滤器大型阵列选择正确的模式 - Rest vs Local Array

Wich is the best approach for an app that aims to filter data, like 5000+ records, by keeping the response speed in focus?

A) Filter local memory arrays B) Query to db trought http api request calls

For my app i use angularjs, php and SQLite3. Right now i load all record from slite db to my table and then filter this field by search. All work great, but when I exceed 3000 records I notice a certain slowing down. By limiting the search on two fields, I get better performance. My doubt is if changing the model and querying the db I get a better performance or not.

A) Local array advantages - i can use JavaScript Array map() Method - low consuming data bandwidht - i can see all records in table before filter - i can work, after loading data, in offline.

A) Local array disadvantages - slowing down performance over 2000 record.

So can you help me to evaluate advantages and disavantages if i make http api call for any filter action request keeping in focus the performances?

Thank You

  • 写回答

1条回答 默认 最新

  • dsriya5471 2018-11-20 17:09
    关注

    I can't tell about caching in PHP, but for the AngularJS end, there's an approach you can follow:

    1. When the user searches for the first time, fetch the result(s) from db.
    2. Make 2 copies of the data: one presented to the user directly, another can be stores in a local json with a key value pair approach. 3.Next time the user searches for anything, look into the local json first for the result. If the data is present locally, no need for the db query, else make the db query and repeat step 2.

    The idea is not to make user wait for every search, you cannot simply call all 5000+ records at once and store locally, and you definitely cannot make db queries every-time since RDMS having that much records simply have low performance issues. So this seems best to me.

    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决