JavaScript中建议的外部JSON对象的最大大小 [英] Max recommended size of external JSON object in JavaScript

查看:632
本文介绍了JavaScript中建议的外部JSON对象的最大大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的数据要进行排序和查询,我不能依赖互联网连接。理想情况下,我想将我的整个数据集存储为JSON对象(目前大约17MB,但可能会大得多)并使用类似jLinq或SQLike的方法来查询它,而不是必须输出大量较小的文件。 / p>

我有兴趣使用JavaScript(特别是jQuery)查找外部getJSON调用的最大推荐文件大小。 1MB,20MB,100MB?关于这个问题的信息很少。有关查询大型数据集客户端的信息很少见。



有关此主题的任何信息都将不胜感激。

解决方案

你最大的问题可能是加载时间,因为它必须将它从一串JSON转换成一个真正的JavaScript对象。另一个大问题是整个数据集将在页面的内存中。我不熟悉使用100MB +数据的任何页面。



我做了一个 jsfiddle测试大型JSON字符串的加载性能。看起来只需要大约500毫秒来解析一个~20MB的JSON字符串(在Core i7机器上),而在Chrome中它使用的内存比JSON字符串基本为空的情况多80MB。所以100MB可能需要几秒钟来加载并使用400MB +的内存。



这不会解决这两个问题,但是你考虑过使用 SQL.js ?它是SQLite的JavaScript实现。它应该更容易查询数据。


I have a tremendous amount of data to sort and query, and I can't rely on an internet connection. Ideally, I'd like to store my entire data-set as a JSON object (currently around 17MB, but could get much larger) and use something like jLinq or SQLike to query it, as opposed to having to output numerous smaller files.

I'm interested in finding what the largest recommended filesize is for an external getJSON call using JavaScript (jQuery, specifically). 1MB, 20MB, 100MB? Information on the subject is scarce. Information on querying large data-sets client-side is scarce all around.

Any information on the subject would be greatly appreciated.

解决方案

Your biggest problem will probably be loading time since it will have to convert it from a string of JSON into an actual JavaScript object. The other big problem will be that the entire data set will be in memory for the page. I'm not familiar with any page using 100MB+ of data.

I made a jsfiddle to test loading performance of large JSON strings. It looks like it takes ~500ms just to parse a ~20MB string of JSON (on a Core i7 machine), and in Chrome it uses 80MB more memory than if the JSON string basically empty. So 100MB could take a few seconds to load and use 400MB+ of memory.

This won't solve either of those issues, but have you considered using SQL.js? It is a JavaScript implementation of SQLite. It should make querying that data much easier.

这篇关于JavaScript中建议的外部JSON对象的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆