Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too long Server-side Pagination initial load #467

Open
naho2081 opened this issue Jul 22, 2017 · 4 comments
Open

Too long Server-side Pagination initial load #467

naho2081 opened this issue Jul 22, 2017 · 4 comments

Comments

@naho2081
Copy link

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?

@geremora
Copy link

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

@naho2081
Copy link
Author

naho2081 commented Aug 10, 2017

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.

@geremora
Copy link

Thanks @naho2081!

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

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

@goolz
Copy link

goolz commented Jan 1, 2019

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 added a commit to goolz/reactive-table that referenced this issue Jan 1, 2019
for big data observeChanges should be disabled
aslagle#467
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants