reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

Too long Server-side Pagination initial load

Open naho2081 opened this issue 7 years ago • 4 comments

I have a collection with 40K records and have configured Server-side Pagination:

SERVER:
collectionData = ->
  if @userId
    allRecordsCollection
  else
    []
ReactiveTable.publish 'allRecords', collectionData

CLIENT:
+reactiveTable collection="allRecords" settings=settings

As a result initial table load takes around 7-8 seconds on production server and generates table with 2K pages. When initial load finished, navigation by pages works quickly and Filtering also works quickly. When Filter is cleared table load time is again 7-8 seconds.

Questions:

  1. Why Server-side Paginations takes so much time? It loads whole collection from MongoDB?
  2. Maybe it is possible to speed up somehow table load in following cases?:
  • If it is initial load
  • If Filter was applied and than cleared

In fact I don't need such a huge table with thousands of pages when no filter is applied. It will be even enough to show initially empty table but with filter input shown. And only after any search query is entered in filter field table will be populated with data.

Any comments?

naho2081 avatar Jul 22 '17 19:07 naho2081

I'm having the same problem. Even with the ReactiveTable.publish the initial load takes so much time around of 5 or 6 seconds.

geremora avatar Aug 10 '17 11:08 geremora

Hey @geremora

This problem appears because full collection is pulled from MongoDB (either by Client, or Server (with Server Side Pagination). But in fact no one needs full collection with hundreds of thousands records. Anyway you will filter the table to find subset of records.

So, I have found solution how to avoid such a long wait time and optimize overall performance. Server Side Pagination is not needed for that.

I have added custom filter fields for columns in the table which I use most often for filtering like

.input-group
	span.input-group-addon Search request
	input.searchRequest

And only when user enters some text in this search field, I transform it to Mongo request format and use conditional Meteor subscription.

Client: (textRequestField if reactiveVar that is changed when .searchRequest input is changed)

records: ->
	matchConditions["filedTitle"] = textRequestField.get()
	Meteor.subscribe "collectionRecords", matchConditions
	return Collection.find matchConditions

+reactiveTable collection=allMegaindexVisibility settings=settings

Server

Meteor.publish "collectionRecords", (matchConditions) ->
	check matchConditions, Object	
	Collection.find matchConditions
	,
		limit: 300

With such config you will have always not more than 300 records in your table that will be more than enough for further filtering using reactive-table functionality.

Hope this will help.

naho2081 avatar Aug 10 '17 18:08 naho2081

Thanks @naho2081!

I thought that the ReactiveTable.publish not pull all of records :(

Your solution looks good I'm going in that way.

geremora avatar Aug 11 '17 16:08 geremora

I had a same problem. the problem is issue with fullCursor.observeChanges

try to disable observeChanges by using the followed setting:

{
  disablePageCountReactivity: true
}

also you can add disableRowReactivity: true to the setting

full publish code would be like this:

ReactiveTable.publish("publishName", collection, {}, {
  disablePageCountReactivity: true,
  disableRowReactivity: true
});

goolz avatar Jan 01 '19 08:01 goolz