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

perf(db): optimise indices of mail tables #9295

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

JohannesGGE
Copy link
Contributor

@JohannesGGE JohannesGGE commented Feb 5, 2024

Fix: #9162

Needs nextcloud/server#43209 to also replace indices.

What should happen:

oc_mail_messages

  • add index on structure_analyzed -> mail_messages_strucanalyz_idx
  • drop index mail_messages_mailbox_id because mail_messages_mb_id_uid already contains mailbox_id on first position
  • make mail_messages_mb_id_uid unique -> mail_messages_mb_id_uid_uidx

oc_mail_classifiers

  • add index on created_at -> mail_class_creat_idx

oc_mail_accounts

  • add index on provisioning_id -> mail_acc_prov_idx

oc_mail_smime_certificates

  • extend mail_smime_certs_uid_idx to cover (user_id,email_address) -> mail_smime_certs_uid_email_idx
  • drop mail_smime_certs_id_uid_idx

oc_mail_tags

  • drop mail_msg_tags_usr_id_index because mail_msg_tags_usr_lbl_idx already contains user_id on first position

oc_mail_aliases

  • add index on account_id -> mail_alias_accid_idx

oc_mail_trusted_senders

  • add index on (user_id,email,type) and drop mail_trusted_senders_type -> mail_trusted_senders_idx

oc_mail_coll_addresses

  • add index on (user_id, email, display_name) and drop mail_coll_addr_userid_index and mail_coll_addr_email_index -> mail_coll_idx

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment out the index creation in the migration that added the indices originally

@JohannesGGE
Copy link
Contributor Author

I commented out the index creation of the indices to drop.

It would be possible to also comment out the creation of the indices that are replaced and add the new ones in the migration, to have new instances up to date without "occ missingindices". The Migration will have a lot of checks in this case, which can be confusing. What do you think?

Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works. I'd suggest to keep the new indices out of old migrations to keep it clean.

@ChristophWurst ChristophWurst force-pushed the perf/9162/db-optimisation branch from 29a83e7 to 4c356d6 Compare February 27, 2024 19:26
@ChristophWurst ChristophWurst merged commit 9c75dc0 into main Feb 28, 2024
36 of 37 checks passed
@ChristophWurst ChristophWurst deleted the perf/9162/db-optimisation branch February 28, 2024 00:56
Copy link

github-actions bot commented Apr 3, 2024

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v3.5+ DB performance analysis
4 participants