- πΊπΈUnited States jrockowitz Brooklyn, NY
I am open to any performance improvements.
The patch would add the index to new installations and provide an update hook for existing installations.
- πΊπΈUnited States greggles Denver, Colorado, USA
Sorry I didn't followup on this. It did dramatically improve performance in our environment, particularly on a crucial operation, and it did not cause any noticeable problems with webform inserts.
I'm having performance issues with certain webform queries as well. The webform_submission_data table comprises nearly 24% of one database, taking up over 28M, though I'm sure greggles' is larger.
I'm using webform views (see this performance issue π Reverse Entity Webform Submission Relationship is slow on MariaDB <= 10.5 Active ), and adding submission fields into the view means that the webform_submission_data table is joined once for every field.
I tried adding an index, and using
ANALYZE
on the query I'm testing shows that the number of rows improves dramatically.Before:
- select_type: SIMPLE
- table: webform_submission_data
- type: ALL
- possible_keys: webform_id
- key: \N
- key_len: \N
- ref: \N
- rows: 159725
- r_rows: 154624
- filtered: 15.86
- r_filtered: 0
- Extra: Using where; Using join buffer (flat, BNL join)
Afterward:
- select_type: SIMPLE
- table: webform_submission_data
- type: ref
- possible_keys: webform_id,ix_webform_submission_data_name_property
- key: ix_webform_submission_data_name_property
- key_len: 514
- ref: const
- rows: 5214
- r_rows: 5214.00
- filtered: 15.86
- r_filtered: 0.03
- Extra: Using where
Adding the index improves the query execution time quite a bit as well.
I would also like to mention that if we add a patch/MR, it maybe should check if the index already exists, because someone might have created it like greggles did.
- Merge request !422Issue #3315197: Add index webform_submission_data (name, property) β (Open) created by solideogloria
- Open on Drupal.org βCore: 10.1.4 + Environment: PHP 8.2 & MySQL 8last update
about 1 year ago Waiting for branch to pass - Status changed to Needs review
about 1 year ago 9:58pm 20 March 2024 I'm new to adding indexed and how Drupal does this. I copied the examples I could find in existing code. Please review.
Note that I didn't use the same index name that was suggested in the workaround, which used
create index ix_webform_submission_data_name_property on webform_submission_data (`name`, `property`);
The new index is
name_property
and is essentially added with the Drupal DB abstraction layer version of:ALTER TABLE webform_submission_data ADD INDEX name_property (`name`, `property`);
You can see existing indexes on the table with
SHOW INDEXES FROM webform_submission_data;
You can drop the workaround index with
DROP INDEX ix_webform_submission_data_name_property ON webform_submission_data;
- last update
about 1 year ago 506 pass, 48 fail - Open on Drupal.org βCore: 10.1.4 + Environment: PHP 8.2 & MySQL 8last update
about 1 year ago Waiting for branch to pass I changed the hook to
webform_update_9600
, because it wasn't running. The module currently supports a minimum of Drupal 9.4, and the module version is 6.2.x, so N is 9600.I tried including
delta
in the index as well, but I didn't see any difference/benefit. Does anyone think that should be included, or is the MR good as-is?As a note, I think documentation should be added to say that the following could greatly improve SQL query performance.
Put in my.cnf on the DB server, or in .ddev/mysql/my.cnf
[server] # Greatly improves performance of some SQL queries. optimizer_search_depth = 0
- Status changed to Needs work
about 1 year ago 2:26pm 3 April 2024 After applying the update, the site's status report has an error:
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.Webform submission
- The Webform submission entity type needs to be updated.
- Assigned to solideogloria
To fix it after having applied the (not quite correct) patch, run
drush webform:repair
I will apply a fix to the MR soon. It's an easy fix.
- Open on Drupal.org βCore: 10.1.4 + Environment: PHP 8.2 & MySQL 8last update
about 1 year ago Waiting for branch to pass - Issue was unassigned.
- Status changed to Needs review
about 1 year ago 2:46pm 3 April 2024 I would like to note that in MySQL and MariaDB, setting
optimizer_search_depth=0
also has a huge performance boost.Could someone please review this? It's a significant performance increase, and it'd be nice to have this included for everyone.
- Status changed to Needs work
11 months ago 10:37am 23 July 2024 - Status changed to Needs review
11 months ago 2:56pm 23 July 2024 - Status changed to RTBC
11 months ago 7:21pm 23 July 2024 - Status changed to Needs work
10 months ago 12:12pm 24 July 2024 - π¨π¦Canada Liam Morland Ontario, CA π¨π¦
Tests do not pass. This probably needs a rebase.
- Status changed to Needs review
10 months ago 4:29pm 24 July 2024 Could someone please review this? I've been using these changes successfully in production for around a year.
- π¨π¦Canada dallen33
This works very well on my end. Prior to this I was unable to delete the submissions of a webform with 20,000 submissions (it would timeout). With this update, it works flawlessly.
@liam morland You should make a new feature branch. It'll be a lot easier to just copy in the changes, rather than trying to rebase everything from 6.2.x onto 6.3.x
This is so that the old merge request remains on the old base branch, to allow work on a backport and for the benefit of users still on that version. It is a good idea to use a logical name such as a suffix based on the new base branch to keep the issue fork's branches easy to understand.
https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-dr... β
- Merge request !639Issue #3315197: Add index webform_submission_data (name, property) β (Open) created by solideogloria
solideogloria β changed the visibility of the branch 6.3.x to hidden.