Wagtail: Unwanted wagtail queries on every page

I use Wagtail 5.2 and have on everypage this three queries. enter image description here

Why is Wagtail doing this?

Even if I go to www.example.com/admin/ (Default Django admin page) I can see this three queries?

  1. Is this the default behavior or I am doing something wrong?
  2. Is it possible to cache at least the first query somehow? I guess wagtail is trying to get for each the current site objects.

That is the expected behavior - assuming you mean the Wagtail admin rather than the Django admin.

The first figures out what site you are on. You may only have one site configured but Wagtail inherently supports multiple sites. The next 2 are probably for building the page explorer in the most efficient way possible. If your database is anywhere close to tuned, that data will probably be in memory in the db so I wouldn't worry too much about these queries.

One thing I did learn the hard way, use the Title field in your page models for the title in your front end navigation. That will allow building your nav to be a single query to the wagtailcore_page table. If the navigation title and the title displayed on the page have to be different, make the one displayed on the page be the custom field.

Back to Top