⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Take too much time to load the page, Enterprise-v2.3.1



nasir123

nasir123
  • profile picture
  • Member

Posted 22 March 2018 - 10:55 AM

Hi Team,

 

I am using Enterprise-v2.3.1 of grocery crud. It works fine but when I create a relationship with a table which has thousands of records, it takes too much time to load the page, between 26 seconds to 40 seconds, sometimes even more.

 

One solution could be to create relationship only for add/edit page and ignore relationship on listing page. But I am not sure if it is possible. Any help will be highly appreciated. Thanks in advance.


langfjord

langfjord
  • profile picture
  • Member

Posted 28 March 2018 - 10:26 AM

+1 for that.

 

This is the one remaining question, having tested Grocery Crud Enterprice on larger projects. Using setRelation against larger tables does not function good out of the box and I have still not found a solid workaround. The default behavior of processing the whole table in setRelation slows down the process both on the server and the client side and sometimes resulting in errors as resources dries out. As for now Im awoiding the problem by not using Gracery Crud for such views, but I would love to see a solution on the matter. Even a solid workaround. Maybe someone here with longer experience with the product has found a way to deal with this.

 

For me the problem is present both in the List, New and Edit context, producing dropdown menus with all the records from the joined table. Some sort of search functionality with a limited number of records showing in the dropdown would be the best solution in my mind and where not all the data is downloaded at once. Something like select2.org. 

 

Any inputs would be highly appreciated.


langfjord

langfjord
  • profile picture
  • Member

Posted 29 March 2018 - 08:06 AM

For the record, I just tested the actual load time and data transfer out of the mysql database using such a setup.

 

Setup

GC: Enterprise 2.4.0

Hardware: Virtual machines running on amazon mysql aurora database t2.small (2GB ram) and amazon linux instance on a t2.micro (1GB ram).

Crud: List a single record in a table with setRelation against a large database of about 90.000 records.

Cache: Off

Environment: Development

 

Results

Time to load List/Edit/Add view: 10-20 seconds

Data transfer out of database: ~20MB for every request to see one of the views List/Edit/Add

 

This is similar to what I have previously seen and in the range of nasir123's observations. 

 

I believe the best way to deal with this would be to add some functionality to the core. There could be a setRelationDB or even an automatic detection if we could live with a extra query.

 

Anyway, in any form dealing with this in the List view would probably be the easiest part, since we only need to prevent the data fetching of the whole corresponding relational table and replacing the dropdown menu with the already implemented Quick Search box (I have already unsuccessfully tried to do this with the api tools). 

 

Dealing with this in the Add and Edit view is another story. One way could be to add dummy field with search functionality, using a tool like Select2 or similar, passing data to the raw ID of the collumn you would normally set relation to. Such solution would however require an endpoint where the searchbox would fetch data from. 


langfjord

langfjord
  • profile picture
  • Member

Posted 29 March 2018 - 11:04 AM

One solution could be to create relationship only for add/edit page and ignore relationship on listing page. But I am not sure if it is possible. Any help will be highly appreciated. Thanks in advance.

 

By the way, you can always try this nasir123:

 

if ($crud->getState() == 'EditForm' | $crud->getState() == 'AddForm') {
$crud->setRelation('customer_id', 'customers', 'customer');
}

 

Edit: Just tried this, and it does not work as expected. At least not for me. 


nasir1234

nasir1234
  • profile picture
  • Member

Posted 02 April 2018 - 02:24 AM

Thanks langfjord for your message and guidelines. I forgot my password of the previous account and was not able to reset by email, so I have to create my new account. That is another issue that should consider by admin :)

 

I tried your described solution, and it's not working for me also. Hopefully, someone will help us to solve this problem