Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#30040 Introduced a lot of database queries to initial page loads #30250

Closed
JasonPunyon opened this issue May 10, 2024 · 2 comments
Closed

#30040 Introduced a lot of database queries to initial page loads #30250

JasonPunyon opened this issue May 10, 2024 · 2 comments
Labels
bug Something isn't working status/identified This bug has been identified

Comments

@JasonPunyon
Copy link
Contributor

JasonPunyon commented May 10, 2024

Steps to reproduce the problem

You can reproduce this problem by loading the /home page.

Expected behaviour

Fewer round trips to the database

Actual behaviour

Too many round trips to the database

Detailed description

#30040 adds the ability for admins to configure favicons. An effect of that PR is now every time the application.html.haml layout is run (on things like initial loads of /home) a series of queries are sent to the database...

image

All these queries are repeatedly going for one of two rows, the favicon row or the app_icon row.

These queries originate from the site_icon_path calls in the loops here.

%link{ rel: 'icon', href: site_icon_path('favicon', 'ico') || '/favicon.ico', type: 'image/x-icon' }/
- SiteUpload::FAVICON_SIZES.each do |size|
%link{ rel: 'icon', sizes: "#{size}x#{size}", href: site_icon_path('favicon', size.to_i) || frontend_asset_path("icons/favicon-#{size}x#{size}.png"), type: 'image/png' }/
- SiteUpload::APPLE_ICON_SIZES.each do |size|
%link{ rel: 'apple-touch-icon', sizes: "#{size}x#{size}", href: site_icon_path('app_icon', size.to_i) || frontend_asset_path("icons/apple-touch-icon-#{size}x#{size}.png") }/

I don't know what the right number of queries is (I could see two, I could see zero) but this feels like too much.

Mastodon instance

Local development

Mastodon version

v4.3.0-alpha.3

@JasonPunyon JasonPunyon added bug Something isn't working status/to triage This issue needs to be triaged labels May 10, 2024
@ClearlyClaire
Copy link
Contributor

Thanks for your report! The code indeed lacks the caching that is performed in e.g. InstancePresenter. It may make sense to move it to InstancePresenter with caching similar to the other SiteUpload objects.

@renchap renchap added status/identified This bug has been identified and removed status/to triage This issue needs to be triaged labels May 10, 2024
@renchap
Copy link
Sponsor Member

renchap commented May 19, 2024

Fixed by #30259

@renchap renchap closed this as completed May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status/identified This bug has been identified
Projects
None yet
Development

No branches or pull requests

3 participants