Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This query could be sped up by an index. I don't know what function is calling it though. Adding an index on the redirect column speeds it up.
SELECT
base.rid AS rid,
base.hash AS hash,
base.type AS TYPE ,
base.uid AS uid,
base.source AS source,
base.source_options AS source_options,
base.redirect AS redirect,
base.redirect_options AS redirect_options,
base.language AS language,
base.status_code AS status_code,
base.count AS count,
base.access AS access
FROM redirect base
WHERE (
base.redirect = 'node/886244'
)
Comment | File | Size | Author |
---|---|---|---|
#13 | add_index_on_redirect_column-2194099-13.patch | 710 bytes | Vacilando |
|
Comments
Comment #1
Dave ReidI don't know off-hand what would need to query on the redirect field, but I don't think it happens that often (the condition for looking up based on the source column is in fact indexed currently)? That almost sounds like an entity field query.
Comment #2
JvE CreditAttribution: JvE commentedI'm also seeing this non-stop on my new site's production databases processlist:
with the nid constantly changing.
I tracked down the source being the google_analytics_counter module.
I'll go add an index.
Comment #3
Vacilando CreditAttribution: Vacilando commented@Dave Reid, did the info by JvE help? The index would really be helpful.
Comment #4
Vacilando CreditAttribution: Vacilando commentedAttaching a patch that adds the index for new as well as existing installs; please review and commit. Thanks!
Comment #5
rp7 CreditAttribution: rp7 commentedPatch in #4 works.
Tested on a clean Drupal install. Both on installation, and update. Against 7.x-1.0-rc1+8-dev.
Comment #6
nicrodgersPatch 4 looks good to me
Comment #7
nicrodgersComment #10
Vacilando CreditAttribution: Vacilando as a volunteer commentedUpdated patch attached.
Comment #11
Vacilando CreditAttribution: Vacilando as a volunteer commentedSimpleTest OK this time; setting the status back to RTBC.
Comment #12
Dave ReidThe latest patch is missing the index definition in redirect_schema() so this index will not be created for new sites.
Comment #13
Vacilando CreditAttribution: Vacilando as a volunteer commentedOh, indeed, it fell through the cracks when updating the patch.
Line added back to redirect_schema() now — see the new patch.
Comment #14
danquah CreditAttribution: danquah commented+1 on the "Reviewed & tested by the community" - I just applied the patch and ran the update-hook on a quite large site that has 800.000+ redirects. It sped up redirect_field_attach_form() by about 500ms and applying the update-hook took about 10 seconds.
Comment #15
pifagorRTBC
Comment #16
alex_optimLooks good.
Comment #17
pifagorComment #20
pifagorComment #22
ciss CreditAttribution: ciss at yousign GmbH commented@pifagor You accidentally committed the patch in #10 instead of #13. The former is missing the index definition in the schema.
Comment #23
pifagorComment #26
pifagor@ciss, thanks
Comment #27
pifagorComment #28
jackfoust CreditAttribution: jackfoust as a volunteer and at Muni-Link commentedThis change does not appear to work with Pantheon and Drupal 7 without converting to UTF8MB4.
Comment #30
hargobindI just upgraded to the latest 1.x-dev version (26-Jan-2020) on a non-utf8mb4 site and did not run into any errors.
@jackfoust Were you using 1.x or 2.x when you tried updating on your Pantheon site? What errors did you get?
I don't run Pantheon, so I can't test this myself. But given that it's a widely used platform, I think it's worth finding someone to run a few tests on a Pantheon installation and see what they come up with.
Comment #31
pifagorSome info here - https://www.drupal.org/project/redirect/issues/2815099