Jump to content

Change of $page->parent is extremely slow


Dennis Spohr
 Share

Recommended Posts

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

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?

  • Like 1
Link to comment
Share on other sites

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

$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

  • 11 months later...

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

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...