We are trying to make a relation between two collections, accounts and users. Every account has many users. We did that in a easier way through the code like this:
And this is work well on our dev environment, but when we run it on the production Accounts collection page is broken. The reason is that the Forest Admin join these two tables and make a relation between all Accounts and Users at one call. A query is large so FA could not get any response. In some envs it takes about 1 hour to accomplish the query. So this solution is not possible in this case.
Do we have any alternative solution? Maybe smart views could help?
Theoreticlly this procedure could help:
Open a single Account.
Make a query to get all users belongs to opened account.
Present the response.
But we are not sure how to achieve this approach. Any suggestion?
Using Chrome Version 85.0.4183.83.
Yes it’s “forest-express-sequelize”: “^5.2.0”.
It’s happening when we open a collection to list all Accounts. In that moment query is started. If that query is triggered when we open a single record detail it shouldn’t be a problem I guess.
And because of that we could not even see the list of Accounts.
Hmm okey.
Why is Users not showing in your Related Data I thought that Account had many Users no ?
It should already be the case. But I think I missing a important information
Yep, accounts has many users. And we make a relation as on the question of the topic through the code. And code is working perfectly fine on development where we have few hundreds users.
But when we open Accounts page to see all the records. Just accounts, not users. To see users we need to open single account and we could not reach to that step.
Reason is that on the Accounts page Forest Admin make a query to the database to join this 2 tables where we have a lots of data and take to much time to be executed. As result page is not rendered completely.
We could see this example when we try to count users.
The user count on the search bar does not appear.
Pagination is not working.
The same is happen when we make a relation between accounts and users(Accounts page is broken)
But anyway the question is could we somehow implement smart view or scope in detail of a single record? In that way, we could specify queries per account and avoid troubles.
You could override routes, but what I’m worried about is that you should not have any issue by default . So I think there is an issue that we need to fix before trying to getting around it
Just a quick note: Assuming it works locally and not remotely due to timeout there may be a problem with the database size and/or the server configuration. Looking at one of your screenshots, it seems that the users’ table is big.
My best bet is that if you increase your remote server capacity and check what you can tune in your database configuration, it would work faster and better. Even if we would improve some queries, as soon as your database grows, you have to increase your server’s capacity. You may find some ways to optimize (see workaround by @vince) but you would have to rewrite some queries to fine-tune them.
As a side note, I suggest you edit your screenshot to remove all personal information, such as emails, names, and your bearer token; I could do this for you if you prefer)
@rap2h thank you on your note. I do not have an option to edit a message, just remove icon is present. Can you just remove a screenshot, and leave the message?