Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the code I am using for a movie database playground. I experimented with jQuery events, but finally decided that it is enough if the data is transferred continuously. My testing collection is 680 records, with 20 fields and one thumbnail field which is between 10-20kb per cover. Here the Coffeescript code:</p> <pre><code>Movies = new Meteor.Collection("movies") if Meteor.isClient # starting with 10 items that the user sees a page fast Session.set("queryLimit", 10) # getting the item count from the server collection Meteor.call 'getMoviesCount', (err, result) =&gt; Session.set('itemsInQuery',result) # subscribe to a subset of the collection, and change the Session var on completion # automatically changing the limit of the publishing function with autorun Meteor.autorun -&gt; Meteor.subscribe "MoviesList", Session.get("queryLimit"), onComplete = -&gt; if Session.get("queryLimit") &lt; Session.get('itemsInQuery') queryLimit = Session.get("queryLimit") + 30 #change iterator depending on result size Session.set("queryLimit", queryLimit ) # Client helper to add more items to handlebars template Template.app.helpers movies: -&gt; Movies.find({}) if Meteor.isServer Meteor.publish "MoviesList", (limit) -&gt; # show whole collections once limit is reached, by setting limit to 0 limit = 0 if limit &gt; Movies.find().count() console.log new Date(), limit Movies.find({}, { limit: limit, fields: {title:1 } } ) #use fields to test different result sizes Meteor.methods getMoviesCount: (query) -&gt; return Movies.find().count() </code></pre> <p>And the html:</p> <pre><code>&lt;body&gt; {{&gt; app}} &lt;/body&gt; &lt;template name="app"&gt; {{#each movies}} &lt;p&gt;{{title}}&lt;/p&gt; {{/each}} &lt;/template&gt; </code></pre> <p>I did some quick performance test and it turns out that for a few lines of text per record, the quickest way to send data to the client is a limit around 100. I tried it also with 10-20kb thumbnails which are embedded in the file. When using bigger assets Chrome became quite unresponsive when the limit was bigger than 30 records. Here a few stats done on localhost (run 3x each):</p> <pre><code>limit seconds till last record rendered. 0 79s 010 121s 020 64s 030 45s 050 34s 100 16s 200 16s </code></pre> <p>It's interesting to note that it took around 79 s when meteor server sends the whole page in one go (limit=0). I am not sure, how this can be possible, because a continious stream should be the fastest. So there is probably something funny with my stats. Any ideas? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload