Javascript Meteor-大数据集加载缓慢

Javascript Meteor-大数据集加载缓慢,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,我正在MongoDB中处理相当大的数据,并在Meteor应用程序中使用它。然而,数据的大小导致网页的加载速度非常慢 该集合的大小约为17MB,包含84000个文档 使用发布/订阅方法,我有以下代码: 导入->两者->MyCollection.js: import { Mongo } from 'meteor/mongo'; export const statistics = new Mongo.Collection('statistics'); 服务器->Main.js: import {

我正在MongoDB中处理相当大的数据,并在Meteor应用程序中使用它。然而,数据的大小导致网页的加载速度非常慢

该集合的大小约为17MB,包含84000个文档

使用发布/订阅方法,我有以下代码:

导入->两者->MyCollection.js:

import { Mongo } from 'meteor/mongo';

export const statistics = new Mongo.Collection('statistics');
服务器->Main.js:

import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { statistics } from '/imports/both/MyCollection';

Meteor.publish('statistics', function publishSomeData() {
  return statistics.find();
});
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { statistics } from '/imports/both/MyCollection';
import './main.html';

Template.application.onCreated(function applicationOnCreated() {
  this.subscribe('statistics');
});

Template.application.onRendered(function applicationOnRendered() {
this.autorun(() => {
    if (this.subscriptionsReady()) { 
      const statisticsData = statistics.findOne();
      console.log(statisticsData);
    }
  });
});
客户端->Main.js:

import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { statistics } from '/imports/both/MyCollection';

Meteor.publish('statistics', function publishSomeData() {
  return statistics.find();
});
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { statistics } from '/imports/both/MyCollection';
import './main.html';

Template.application.onCreated(function applicationOnCreated() {
  this.subscribe('statistics');
});

Template.application.onRendered(function applicationOnRendered() {
this.autorun(() => {
    if (this.subscriptionsReady()) { 
      const statisticsData = statistics.findOne();
      console.log(statisticsData);
    }
  });
});
就像我说的,这个方法是有效的,控制台记录数据。然而,使用大约60mbps的互联网连接,加载页面和最终控制台记录数据大约需要2分钟,有时我会收到“Google没有响应”警报,我被迫退出

为了避免如此缓慢的加载时间,有什么更有效的方法将数据加载到应用程序中?任何帮助都将不胜感激

非常感谢,


G

限制发布到客户端的数据量

要么只发布统计数据集合的某些字段,要么“延迟加载”文档-将多个docs参数传递给发布,并使用find的
limit
选项只向客户端发送那么多文档

或者,根据需要在服务器上编译数据,并仅将编译后的数据发送到客户端


如果不了解集合的性质,就无法给出更具体的示例。

如果您认为这些解决方案中的任何一种都可能有效,我可以提供一些片段来演示它们的实现。感谢您的回答。我的问题是所有的文件都需要在应用程序中提供给我,所以只发布部分数据对我来说不起作用。如果你有一个我能看到的例子,那么延迟加载对我来说是一个合适的选择!谢谢,这是一个很好的例子。它有几个快速部分,在页面底部有一个“下一部分”按钮。这是否清楚地解释了这种模式?