Skip to content

ElementalArea TopPageID is not used #1415

@AljosaB

Description

@AljosaB

Module version(s) affected

all versions

Description

I'm working on a page with 100k+ pages that have 4 elemental areas. I was tasked to check for performance optimizations and found out that when opening a page in CMS, 4-5 seconds were used for loading up those elemental areas (not elementals). To be specific, initialization of elemental areas triggered ~10 querys to get the owner (page) of the area. Each of those query took ~0.4s and that quickly added up.

As per these instructions TopPageID field is already being added (and populated) to ElementalArea table, but to my surprise ElementalArea::getOwnerPage doesn't seem to be using it at all and is instead doing plenty of loops and queries to DB.

How to reproduce

  1. install Elemental
  2. add many page
  3. open a page in CMS and monitor performance

Possible Solution

if ($this->hasExtension(DataExtension::class) && ($this->TopPageID > 0)) {
    return $this->TopPage();
}

The above code added to ElementalArea::getOwnerPage improves page load time for 50% in my case. (although I do have many areas and lots of pages)

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions