Problem/Motivation

I have a site in development but containing 250 groups (all of one group type) and 6000 nodes as content. Adding new content is *really* slow - taking about 10 seconds from clicking save to seeing the "second" form and another 10 seconds from clicking save on that to seeing a result.

I'm worried if this is going to get worse as content increases?

Tested on both core 8.1.10 and 8.2.0

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Original report by [username]

Comments

rachel_norfolk created an issue. See original summary.

zerolab’s picture

rachel_norfolk’s picture

With the second issue, zerolab, is there something I can check to see if it is implemented in my db? TBH the issue just seems to roll off to closed without a specific patch or conclusion as far as I can see?

zerolab’s picture

For the second issue it was adding a temporary return; at the top of gnode_node_grants()
I lost track of the changes that led to the issue being closed, but we also did not need gnode.

I am sure Kristiaan has plenty of insight on that

rachel_norfolk’s picture

Yes, but that temporary return; kind of assumed that the user adding content was uid=1 didn't it? Kind of defeats the point of the module, surely? I'm feeling more than a bit worried right now if I've made a bad decision. :-/

rachel_norfolk’s picture

Right then - there are acknowledged issues reading the many possible node grants across many possible groups during the rendering of views. I get that.

It strikes me that we *shouldn't* need to run any of those during the creation of *new* group content, though. Surely, the only query that needs to run is the one that says "does this user/role have the ability to add this type of content to *this* group. That should not be creating lots (and I do mean lots - tens of thousands) of queries.

Are we simply querying things that are not needed?

With a little guidance, I can easily justify the work time to look at this - but do need guidance!

kristiaanvandeneynde’s picture

As we discussed on IRC I'm pretty sure it's related to #2796197: Group or Group Node generates some massive queries but please verify by disabling that system, clearing caches and then trying again.

You're looking to disable gnode_node_grants() mainly by making it return an empty array.

rachel_norfolk’s picture

Yes - was good to catch up on IRC and see a way to move this on.

I've tried the patch described above and , for the admin user 1, yes it does dramatically speed up adding new nodes. Basically instant.

So, it strikes me that we need to understand the minimum "query effort" required for each operation against a group. Presumably, that list of operations is something like:

- Create a group entity
- Retrieve a group entity
- Update a Group entity
- Delete a Group entity
- Create a gnode* related to a group
- Retrive a gnode (directly or as part of a view)
- Update a gnode "
- Delete a gnode "
- Create a user relation
- Retrive a user relation
- Update a user relation
- Delete a user relation

I assume that's the list?

*presuming gnode covers same scenarios of other entities

kristiaanvandeneynde’s picture

Status: Active » Closed (duplicate)
Related issues: +#2796197: Group or Group Node generates some massive queries

It's weird that adding a new node would start gathering the user's grants. But then again there may be a reason why it's doing that so I am not going to comment on that as if it were a bug in core.

Perhaps we should further discuss this in #2796197: Group or Group Node generates some massive queries now? Seeing as how you've confirmed that this is the cause of your problem.

I'll add you and zerolab to the credits there.

mwebaze’s picture

Component: Group (group) » Code

I am experiencing this very issue. Adding a new announcement to the group takes way too long. I discovered that SqlContentEntityStorage:save() is called multiple times in Group::addContent. I am currently running Drupal 9.3.3. The grants issue previously discussed doesn't seem to affect me.