Dennis Spohr Posted December 21, 2020 Share Posted December 21, 2020 Hi all, when I update the parent of an existing page, this process takes extremely long (20-30 seconds). $page->of(false); $page->parent = $trash; $page->save(); Sometimes these tested pages doesn't even have a single child-page. Our database is quite large (but with a very fast server): 900.000 entries in the pages table. 90.000 entries in the pages_parents table. Is there any other way to change the parent or does anybody now where this could come from? We have multiple places where this is happening now. Thanks! Dennis Link to comment Share on other sites More sharing options...
adrian Posted December 21, 2020 Share Posted December 21, 2020 Is it only slow when changing the parent to trash, or slow in general? Instead of that approach to trashing pages, have you tried: $page->trash(); https://processwire.com/api/ref/page/trash/ 1 Link to comment Share on other sites More sharing options...
Dennis Spohr Posted December 21, 2020 Author Share Posted December 21, 2020 Changing the parent is slow in general. In my case $trash is my own custom page, not the trash of ProcessWire. I have other places in my code where I change the parent not using my own trash and there I have the same behaviour. Link to comment Share on other sites More sharing options...
adrian Posted December 21, 2020 Share Posted December 21, 2020 What version of PW are you running? In 3.0.156 there were a bunch of changes related to page parents: I am wondering if these changes might help, or if you are already running this (or later version), if it was faster before? 1 Link to comment Share on other sites More sharing options...
Dennis Spohr Posted December 22, 2020 Author Share Posted December 22, 2020 I am running PW 3.0.165, the latest master version. Unfortunately I can’t tell if it was faster before migrating to this version. Sometimes it was kind of slow, but I didn’t look into this in detail before. Today we figured out another problem with parents. When using $page->find() sometimes it doesn’t find an existing page (with $pages->find() it’s there). In this case it has to be something with the has_parent selector. After at least 20 minutes of testing and debugging, it was finally working without us changing anything. Probably the pages_parent table is not working correctly or is created/updated too late. But this doesn’t fix the first issue regarding the performance. Something strange is going on. Link to comment Share on other sites More sharing options...
adrian Posted December 22, 2020 Share Posted December 22, 2020 Perhaps it's worth trying the new: $pages->parents()->rebuildAll(); https://github.com/processwire/processwire/blob/d3b1ab2983108a0410f7c66997f0478e7f3e02e6/wire/core/PagesParents.php#L580 Obviously a DB backup before doing this is essential, or do it on a dev copy of the site. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted December 22, 2020 Author Share Posted December 22, 2020 $pages->parents()->rebuildAll() took around 16 seconds on our dev-server. For now we switched back to pw 3.0.148 and it seems that the error is not happening anymore. Also changing the parent is not as slow anymore. So there's definetely something going on with this new pages_parents table, but we were not able to reproduce the error with $page->find() on purpose. It randomly happened and for sure the pages_parents table was not correct anymore. But somehow fixed after seconds or minutes. Link to comment Share on other sites More sharing options...
adrian Posted December 22, 2020 Share Posted December 22, 2020 Hi @Dennis Spohr - thanks for testing all that. Would you mind posting a issue on Github so that @ryan can track this. Please include a link to this thread. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted December 28, 2020 Author Share Posted December 28, 2020 Sure, just posted it here: https://github.com/processwire/processwire-issues/issues/1297 2 Link to comment Share on other sites More sharing options...
lpa Posted December 23, 2021 Share Posted December 23, 2021 Could you disable the rebuildAll() call for a moment in PagesParents.php, or would it break something? Will it rebuild the indexes after it would be reenabled? Quote We've isolated the issue to line 502 of PagesParents.php, where $this->rebuildAll() is called when the page is moved. Link to comment Share on other sites More sharing options...
Dennis Spohr Posted February 8, 2023 Author Share Posted February 8, 2023 This issue is fixed in the latest commit. ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now