Wagtail SQL call on none wagtail pages
See original GitHub issueHi,
I have included wagtail to my project as a cms system. But I have also some old static pages which also produce allways this SQL call:
SELECT"wagtailcore_site"."id", "wagtailcore_site"."hostname", "wagtailcore_site"."port", "wagtailcore_site"."site_name", "wagtailcore_site"."root_page_id", "wagtailcore_site"."is_default_site", CASEWHEN ("wagtailcore_site"."hostname" = '''127.0.0.1''' AND "wagtailcore_site"."port" = '8000') THEN '0' WHEN ("wagtailcore_site"."hostname" = '''127.0.0.1''' AND "wagtailcore_site"."is_default_site" = 'True') THEN '1' WHEN "wagtailcore_site"."is_default_site" = 'True' THEN '2' ELSE '3' END AS "match", "wagtailcore_page"."id", "wagtailcore_page"."path", "wagtailcore_page"."depth", "wagtailcore_page"."numchild", "wagtailcore_page"."title", "wagtailcore_page"."slug", "wagtailcore_page"."content_type_id", "wagtailcore_page"."live", "wagtailcore_page"."has_unpublished_changes", "wagtailcore_page"."url_path", "wagtailcore_page"."owner_id", "wagtailcore_page"."seo_title", "wagtailcore_page"."show_in_menus", "wagtailcore_page"."search_description", "wagtailcore_page"."go_live_at", "wagtailcore_page"."expire_at", "wagtailcore_page"."expired", "wagtailcore_page"."locked", "wagtailcore_page"."first_published_at", "wagtailcore_page"."last_published_at", "wagtailcore_page"."latest_revision_created_at", "wagtailcore_page"."live_revision_id"FROM "wagtailcore_site" INNER JOIN "wagtailcore_page" ON ("wagtailcore_site"."root_page_id" = "wagtailcore_page"."id") WHERE ("wagtailcore_site"."hostname" = '''127.0.0.1''' OR "wagtailcore_site"."is_default_site" = 'True') ORDER BY "match" ASC | 98,487335358% | 144,35 | SelExpl |
This call takes on my desktop computer (in debug mode with sqlite) 150ms. Is there something wrong?
And why is this SQL query also called on a none wagtail page?
Issue Summary
Wagtail is calling SQL queries which I don’t need
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:14 (1 by maintainers)
Top GitHub Comments
@RNCTX I hope I can get back to this soon! This weekend if I’m lucky. I believe what you’re asking for is also what @ababic was referring to. Apart from that, I hope my test refactors have taken away most if not all doubts about the backward compatibility of this new implementation, which I believe was a concern a few months back.
@RNCTX
request._wagtail_site
will be undefined if you try to access it before the first call toSite.find_for_request
.