Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Cache fallback pages #8544

Closed
wants to merge 7 commits into from
Closed

Cache fallback pages #8544

wants to merge 7 commits into from

Conversation

Toflar
Copy link
Member

@Toflar Toflar commented Oct 26, 2016

I noticed that PageModel::findWithDetails() executes a lot of very identical queries. I figured it was the query to fetch the fallback page. As you can see, whenever you call findWithDetails(), Contao works up the tree and calls the fallback page for every page again, even though the information is already there. I inspected an Isotope installation where there was some heavy querying going on because of that. To give you some numbers: With this fix, the number of queries dropped from 1121 for a page to 394 ;-) So I consider this a quite important bugfix that should go into 3.5.

@leofeyer
Copy link
Member

Agreed. Nevertheless, the query should already be cached by MySQL, so I don't think this will have that big an impact.

@leofeyer leofeyer modified the milestones: 3.5.18, 3.5.19 Oct 26, 2016
@Toflar
Copy link
Member Author

Toflar commented Oct 26, 2016

727 Queries times 0.3 ms. You do the math yourself. :)

leofeyer pushed a commit to contao/core-bundle that referenced this pull request Oct 26, 2016
@leofeyer leofeyer assigned leofeyer and Toflar and unassigned leofeyer Oct 26, 2016
@leofeyer
Copy link
Member

You are right, the impact is huge! Very good find! I have adopted the fix in contao/core-bundle@f9d926d for version 4.2.5. Will also merge the PR for Contao 3.

@aschempp
Copy link
Member

Totally agree, but one thing is flawed: The array must only contain the ID of the model, not the actual object. And retrieve it from the registry using a findByPk call.

@Toflar
Copy link
Member Author

Toflar commented Oct 26, 2016

Updated to use the registry for that stuff (which I was actually building the API for when improving fetching from unique fields, dunno how I could forget about that :D)

parent::onRegister($registry);

// Register this model as being the fallback page for a given dns
if ($this->fallback && !$registry->isRegisteredAlias($this, 'dns-fallback', $this->dns))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should never be possible that there is already an alias for that value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, you're not checking if this is the root page.

parent::onUnregister($registry);

// Unregister the fallback page
if ($registry->isRegisteredAlias($this, 'dns-fallback', $this->dns))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would unregister the not-fallback root page.

leofeyer pushed a commit to contao/core-bundle that referenced this pull request Oct 26, 2016
leofeyer pushed a commit to contao/core-bundle that referenced this pull request Oct 26, 2016
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 27, 2016
### 4.2.5 (2016-10-27)

 * Unlock members after password change (see contao/core#8545).
 * Register an alias for the language fallback page model (see
   contao/core#8544).
 * Correctly calculate the maximum length of tl_files.name (see
   contao/core#8536).
 * Correctly add the headline if a content element is versionized (see
   contao/core#8502).
 * Optimize the DCA sorting filter for date fields (see contao/core#8485).
 * Do not show version entries of deleted files (see contao/core#8480).
 * Redirect the empty URL depending on language and alias name (see
   contao/core#8498).
 * Apply `specialchars()` to widget attributes (see contao/core#8505).
 * Queue the requests when rebuilding the search index (see contao/core#8449).
 * Correctly determine the form field names in the file manager (see #600).
 * Correctly show the maximum file size in the form upload widget (see #595).
 * Correctly encode e-mail addresses in the text element (see #594).
 * Do not parse front end templates twice (see #599).
 * Correctly set host and scheme in the URL generator (see #592).
 * Correctly reload the page and file trees in "edit multiple" mode.
 * Correctly normalize the paths in the symlink command.
@leofeyer
Copy link
Member

leofeyer commented Nov 15, 2016

Merged in 8e9bdd7.

@leofeyer leofeyer closed this Nov 15, 2016
@Toflar Toflar deleted the hotfix/fallback-query-overdose branch December 14, 2016 16:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants